Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Added new features #19

Merged
merged 6 commits into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,518 changes: 1,290 additions & 1,228 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oas-generator",
"version": "1.0.3",
"version": "2.0.1",
"description": "OAS code generator",
"main": "src/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions specs/adafruitCom-2.0.0-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ openapi: 3.0.0
servers:
- url: 'https://io.adafruit.com/api/v2'
- url: 'http://io.adafruit.com/api/v2'
- url: 'http://localhost:8080/api/v2'
info:
description: >+
### The Internet of Things for Everyone
Expand Down
2 changes: 2 additions & 0 deletions specs/api-with-examples.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
openapi: "3.0.0"
servers:
- url: 'http://localhost:8080/'
info:
title: Simple API overview
version: v2
Expand Down
1 change: 1 addition & 0 deletions specs/bbc_com1_0_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ openapi: 3.0.0
servers:
- url: 'http://programmes.api.bbc.com/nitro/api'
- url: 'https://programmes.api.bbc.com/nitro/api'
- url: 'http://localhost:8080/nitro/api'
info:
contact:
email: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions specs/callback-example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
openapi: 3.0.0
servers:
- url: 'http://localhost:8080/'
info:
title: Callback Example
version: 1.0.0
Expand Down
1 change: 1 addition & 0 deletions specs/cisco.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://api.cisco.com/'
- url: 'http://localhost:8080/'
info:
contact:
email: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions specs/complexPaths.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
openapi: "3.0.0"
servers:
- url: 'http://localhost:8080/'
info:
version: 1.0.0
title: Pets API -> Valid OASdoc
Expand Down
1 change: 1 addition & 0 deletions specs/docker-engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ openapi: 3.0.0
servers:
- url: 'http://docker.local/v1.33'
- url: 'https://docker.local/v1.33'
- url: 'http://localhost:8080/v.33'
info:
description: >
The Engine API is an HTTP API served by Docker Engine. It is the API the
Expand Down
1 change: 1 addition & 0 deletions specs/github.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://api.github.com/'
- url: 'http://localhost:8080/'
x-hasEquivalentPaths: true
info:
description: >
Expand Down
2 changes: 2 additions & 0 deletions specs/link-example.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
openapi: 3.0.0
servers:
- url: 'http://localhost:8080/'
info:
title: Link Example
version: 1.0.0
Expand Down
5 changes: 5 additions & 0 deletions specs/oai-spec-pets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"openapi": "3.0.0",
"servers": [
{
"url": "http://localhost:8080/"
}
],
"info": {
"version": "1.0.0",
"title": "Valid-OASdoc",
Expand Down
2 changes: 2 additions & 0 deletions specs/oai-spec-pets.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
openapi: "3.0.0"
servers:
- url: 'http://localhost:8080/'
info:
version: 1.0.0
title: Pets API -> Valid OASdoc
Expand Down
3 changes: 2 additions & 1 deletion specs/oai-spec-sosElections.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
openapi: 3.0.0
servers: []
servers:
- url: 'http://localhost:8080/'
info:
description: Sos API contains information about Spain's 2016 general elections results.
contact:
Expand Down
2 changes: 1 addition & 1 deletion specs/oai-spec-talkVotes.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.0
servers:
- url: /api/v1
- url: http://localhost:8080/api/v1
info:
description: API for managing votes on talks
version: 1.0.0
Expand Down
5 changes: 4 additions & 1 deletion specs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
},
{
"url": "http://openapi-converter.herokuapp.com/api/v1"
},
{
"url": "http://localhost:8080/api/v1"
}
],
"info": {
Expand All @@ -24,7 +27,7 @@
"termsOfService": "https://opensource.org/licenses/MIT"
},
"externalDocs": {
"uri": "https://github.com/mermade/openapi-webconverter",
"uri": "https://github.com/mermade/openapi-webconverter"
},
"security": [],
"tags": [
Expand Down
3 changes: 3 additions & 0 deletions specs/petstore-expanded.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"servers": [
{
"url": "http://petstore.swagger.io/api"
},
{
"url": "http://localhost:8080/api"
}
],
"info": {
Expand Down
1 change: 1 addition & 0 deletions specs/petstore-expanded.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: http://petstore.swagger.io/api
- url: http://localhost:8080/api
paths:
/pets:
get:
Expand Down
1 change: 1 addition & 0 deletions specs/petstore-with-external-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/api'
- url: 'http://localhost:8080/api'
info:
version: 1.0.0
title: Swagger Petstore
Expand Down
1 change: 1 addition & 0 deletions specs/petstore-with-external-docsERROR.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/api'
- url: 'http://localhost:8080/api'
info:
version: 1.0.0
title: Swagger Petstore
Expand Down
1 change: 1 addition & 0 deletions specs/slack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://slack.com/api'
- url: 'http://localhost:8080/api'
info:
description: >-
One way to interact with the Slack platform is its HTTP RPC-based Web API, a
Expand Down
1 change: 1 addition & 0 deletions specs/spotify.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://api.spotify.com/v1'
- url: 'http://localhost:8080/v1'
info:
title: Spotify
version: v1
Expand Down
1 change: 1 addition & 0 deletions specs/twitter.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://api.twitter.com/1.1'
- url: 'http://localhost:8080/1.1'
info:
contact:
email: [email protected]
Expand Down
1 change: 1 addition & 0 deletions specs/uber.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openapi: 3.0.0
servers:
- url: 'https://api.uber.com/v1'
- url: 'http://localhost:8080/v1'
info:
title: Uber API
description: Move your app forward with the Uber API
Expand Down
1 change: 1 addition & 0 deletions specs/uspto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ servers:
- 'https'
- 'http'
default: 'https'
- url: 'http://localhost:8080/ds-api'
info:
description: >-
The Data Set API (DSAPI) allows the public users to discover and search
Expand Down
7 changes: 6 additions & 1 deletion src/auxiliary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var options_object = {
loglevel: 'info',
strict: false,
router: true,
validator: true
validator: true,
docs: true
};

oasTools.configure(options_object);
Expand All @@ -29,6 +30,10 @@ oasTools.initialize(oasDoc, app, function() {
http.createServer(app).listen(serverPort, function() {
console.log("App running at http://localhost:" + serverPort);
console.log("________________________________________________________________");
if (options_object.docs !== false) {
console.log('API docs (Swagger UI) available on http://localhost:' + serverPort + '/docs');
console.log("________________________________________________________________");
}
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function generateServer(file, cmd) {
fs.appendFileSync(process.cwd() + '/controllers/' + controllerName + "Service.js", "'use strict'\n\n");
}
var function_string = "module.exports." + opId + " = function " + opId + " (req, res, next) {\n" + controllerVariable + "." + opId + "(req.swagger.params, res, next);\n};\n\n";
var function_string_service = "module.exports." + opId + " = function " + opId + " (req, res, next) {\nres.send({message: 'This is the raw controller for " + opId + "' });\n};\n\n";
var function_string_service = "module.exports." + opId + " = function " + opId + " (req, res, next) {\nres.send({message: 'This is the mockup controller for " + opId + "' });\n};\n\n";
fs.appendFileSync(process.cwd() + '/controllers/' + controllerName + ".js", function_string);
fs.appendFileSync(process.cwd() + '/controllers/' + controllerName + "Service.js", function_string_service);
}
Expand Down