-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from MartinSunal/issue-209
Added openbackhaul-oas3-tools
- Loading branch information
Showing
36 changed files
with
5,005 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.iml | ||
**/node_modules/ | ||
**/npm-debug.log | ||
bower_components/ | ||
coverage/ | ||
.idea/ | ||
dist/ | ||
test/1.2/test-specs-browser.js | ||
test/2.0/test-specs-browser.js | ||
test/*/browser | ||
.tern-project | ||
.project | ||
.settings/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"bitwise": true, | ||
"browser": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"esnext": true, | ||
"immed": true, | ||
"indent": 2, | ||
"latedef": true, | ||
"laxcomma": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"node": true, | ||
"quotmark": "single", | ||
"regexp": true, | ||
"smarttabs": true, | ||
"strict": true, | ||
"trailing": true, | ||
"undef": true, | ||
"unused": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Apigee Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Swagger-UI and API REST Routing for Open API v3. | ||
|
||
Project is forked from https://github.com/paxet-io/oas3-tools release v2.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: Swagger Petstore | ||
description: | | ||
This is a sample Petstore server. You can find | ||
out more about Swagger at | ||
[http://swagger.io](http://swagger.io) or on | ||
[irc.freenode.net, #swagger](http://swagger.io/irc/). | ||
termsOfService: http://swagger.io/terms/ | ||
contact: | ||
email: [email protected] | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
version: 1.0.0 | ||
externalDocs: | ||
description: Find out more about Swagger | ||
url: http://swagger.io | ||
servers: | ||
- url: / | ||
tags: | ||
- name: pet | ||
description: Everything about your Pets | ||
externalDocs: | ||
description: Find out more | ||
url: http://swagger.io | ||
paths: | ||
/pet: | ||
post: | ||
tags: | ||
- pet | ||
summary: Add a new pet to the store | ||
operationId: addPet | ||
requestBody: | ||
$ref: '#/components/requestBodies/Pet' | ||
responses: | ||
"405": | ||
description: Invalid input | ||
security: | ||
- petstore_auth: | ||
- write:pets | ||
- read:pets | ||
x-swagger-router-controller: Pet | ||
/pet/findByStatus: | ||
get: | ||
tags: | ||
- pet | ||
summary: Finds Pets by status | ||
description: Multiple status values can be provided with comma separated strings | ||
operationId: findPetsByStatus | ||
parameters: | ||
- name: status | ||
in: query | ||
description: Status values that need to be considered for filter | ||
required: true | ||
style: form | ||
explode: true | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
default: available | ||
enum: | ||
- available | ||
- pending | ||
- sold | ||
- name: sessionid | ||
in: cookie | ||
required: false | ||
style: form | ||
explode: true | ||
schema: | ||
type: string | ||
responses: | ||
"200": | ||
description: successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Pet' | ||
x-content-type: application/json | ||
application/xml: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Pet' | ||
"400": | ||
description: Invalid status value | ||
security: | ||
- petstore_auth: | ||
- write:pets | ||
- read:pets | ||
x-swagger-router-controller: Pet | ||
|
||
/pet/{petId}: | ||
get: | ||
tags: | ||
- pet | ||
summary: Find pet by ID | ||
description: Returns a single pet | ||
operationId: getPetById | ||
parameters: | ||
- name: petId | ||
in: path | ||
description: ID of pet to return | ||
required: true | ||
style: simple | ||
explode: false | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
"200": | ||
description: successful operation | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
application/xml: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
"400": | ||
description: Invalid ID supplied | ||
"404": | ||
description: Pet not found | ||
security: | ||
- api_key: [] | ||
x-swagger-router-controller: Pet | ||
|
||
components: | ||
schemas: | ||
Category: | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
example: | ||
name: name | ||
id: 6 | ||
xml: | ||
name: Category | ||
Pet: | ||
required: | ||
- name | ||
- photoUrls | ||
type: object | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
category: | ||
$ref: '#/components/schemas/Category' | ||
name: | ||
type: string | ||
example: doggie | ||
photoUrls: | ||
type: array | ||
xml: | ||
name: photoUrl | ||
wrapped: true | ||
items: | ||
type: string | ||
status: | ||
type: string | ||
description: pet status in the store | ||
enum: | ||
- available | ||
- pending | ||
- sold | ||
example: | ||
photoUrls: | ||
- photoUrls | ||
- photoUrls | ||
name: doggie | ||
id: 0 | ||
category: | ||
name: name | ||
id: 6 | ||
tags: | ||
- name: name | ||
id: 1 | ||
- name: name | ||
id: 1 | ||
status: available | ||
xml: | ||
name: Pet | ||
requestBodies: | ||
Pet: | ||
description: Pet object that needs to be added to the store | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
application/xml: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
required: true | ||
securitySchemes: | ||
bearer: | ||
type: http | ||
scheme: bearer | ||
petstore_auth: | ||
type: oauth2 | ||
flows: | ||
implicit: | ||
authorizationUrl: http://petstore.swagger.io/oauth/dialog | ||
scopes: | ||
write:pets: modify pets in your account | ||
read:pets: read your pets | ||
api_key: | ||
type: apiKey | ||
name: api_key | ||
in: header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var utils = require('../utils/writer.js'); | ||
var Pet = require('../services/PetService'); | ||
|
||
module.exports.addPet = function addPet (req, res, next, body) { | ||
Pet.addPet(body) | ||
.then(function (response) { | ||
utils.writeJson(res, response); | ||
}) | ||
.catch(function (response) { | ||
utils.writeJson(res, response); | ||
}); | ||
}; | ||
|
||
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next, status, sessionid) { | ||
|
||
Pet.findPetsByStatus(status,sessionid) | ||
.then(function (response) { | ||
utils.writeJson(res, response); | ||
}) | ||
.catch(function (response) { | ||
utils.writeJson(res, response); | ||
}); | ||
}; | ||
|
||
module.exports.getPetById = function getPetById (req, res, next, petId) { | ||
Pet.getPetById(petId) | ||
.then(function (response) { | ||
utils.writeJson(res, response); | ||
}) | ||
.catch(function (response) { | ||
utils.writeJson(res, response); | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var http = require('http'); | ||
|
||
var oas3Tools = require('oas3-tools'); | ||
var serverPort = 8080; | ||
|
||
function validate(request, scopes, schema) { | ||
// security stuff here | ||
return true; | ||
} | ||
|
||
// swaggerRouter configuration | ||
var options = { | ||
routing: { | ||
controllers: path.join(__dirname, './controllers') | ||
}, | ||
logging: { | ||
format: 'combined', | ||
errorLimit: 400 | ||
}, | ||
openApiValidator: { | ||
|
||
validateSecurity: { | ||
handlers: { | ||
petstore_auth: validate, | ||
api_key: validate | ||
} | ||
} | ||
} | ||
}; | ||
|
||
|
||
var expressAppConfig = oas3Tools.expressAppConfig(path.join(__dirname, 'api/petstore.yaml'), options); | ||
var app = expressAppConfig.getApp(); | ||
|
||
// Initialize the Swagger middleware | ||
http.createServer(app).listen(serverPort, function () { | ||
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort); | ||
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort); | ||
}); |
Oops, something went wrong.