Merge pull request #2466 from wing328/nodejs_method_name

[NodeJS] fix operationId issue with Nodejs
This commit is contained in:
wing328 2016-04-09 18:53:55 +08:00
commit 5522edac0c
9 changed files with 129 additions and 355 deletions

1
.gitignore vendored
View File

@ -43,6 +43,7 @@ samples/server-generator/scalatra/output/.history
# nodejs
samples/server-generator/node/output/node_modules
samples/server/petstore/nodejs/node_modules
samples/server/petstore/nodejs-server/node_modules
# qt5 cpp
samples/client/petstore/qt5cpp/PetStore/moc_*

View File

@ -8,7 +8,7 @@ info:
For this sample, you can use the api key `special-key` to test the authorization filters
version: "1.0.0"
title: Swagger Petstore
termsOfService: http://helloreverb.com/terms/
termsOfService: http://swagger.io/terms/
contact:
name: apiteam@swagger.io
license:

View File

@ -1,53 +1,40 @@
---
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about\n\
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\n\
For this sample, you can use the api key `special-key` to test the authorization\
\ filters.\n"
description: "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io)\
\ or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample,\
\ you can use the api key `special-key` to test the authorization filters\n"
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
name: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Access to Petstore orders"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes:
- "http"
paths:
/pet:
/pets:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
required: false
schema:
$ref: "#/definitions/Pet"
responses:
@ -55,25 +42,26 @@ paths:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
put:
tags:
- "pet"
summary: "Update an existing pet"
description: ""
operationId: "updatePet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
required: false
schema:
$ref: "#/definitions/Pet"
responses:
@ -85,32 +73,27 @@ paths:
description: "Validation exception"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
/pet/findByStatus:
/pets/findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
description: "Multiple status values can be provided with comma seperated strings"
operationId: "findPetsByStatus"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
required: true
required: false
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
collectionFormat: "multi"
responses:
200:
@ -123,25 +106,25 @@ paths:
description: "Invalid status value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
/pet/findByTags:
/pets/findByTags:
get:
tags:
- "pet"
summary: "Finds Pets by tags"
description: "Muliple tags can be provided with comma separated strings. Use\n\
tag1, tag2, tag3 for testing.\n"
description: "Muliple tags can be provided with comma seperated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: "findPetsByTags"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "tags"
in: "query"
description: "Tags to filter by"
required: true
required: false
type: "array"
items:
type: "string"
@ -157,24 +140,24 @@ paths:
description: "Invalid tag value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
deprecated: true
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
/pet/{petId}:
/pets/{petId}:
get:
tags:
- "pet"
summary: "Find pet by ID"
description: "Returns a single pet"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "getPetById"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to return"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
format: "int64"
@ -189,55 +172,59 @@ paths:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
post:
tags:
- "pet"
summary: "Updates a pet in the store with form data"
description: "null"
description: ""
operationId: "updatePetWithForm"
consumes:
- "application/x-www-form-urlencoded"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be updated"
required: true
type: "integer"
format: "int64"
type: "string"
- name: "name"
in: "formData"
description: "Updated name of the pet"
required: false
required: true
type: "string"
- name: "status"
in: "formData"
description: "Updated status of the pet"
required: false
required: true
type: "string"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
delete:
tags:
- "pet"
summary: "Deletes a pet"
description: ""
operationId: "deletePet"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "api_key"
in: "header"
required: false
description: ""
required: true
type: "string"
- name: "petId"
in: "path"
@ -247,86 +234,27 @@ paths:
format: "int64"
responses:
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
description: "Invalid pet value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
- "write_pets"
- "read_pets"
x-swagger-router-controller: "Pet"
/pet/{petId}/uploadImage:
post:
tags:
- "pet"
summary: "uploads an image"
operationId: "uploadFile"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "petId"
in: "path"
description: "ID of pet to update"
required: true
type: "integer"
format: "int64"
- name: "additionalMetadata"
in: "formData"
description: "Additional data to pass to server"
required: false
type: "string"
- name: "file"
in: "formData"
description: "file to upload"
required: false
type: "file"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/ApiResponse"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-swagger-router-controller: "Pet"
/store/inventory:
get:
tags:
- "store"
summary: "Returns pet inventories by status"
description: "Returns a map of status codes to quantities"
operationId: "getInventory"
produces:
- "application/json"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "integer"
format: "int32"
security:
- api_key: []
x-swagger-router-controller: "Store"
/store/order:
/stores/order:
post:
tags:
- "store"
summary: "Place an order for a pet"
description: ""
operationId: "placeOrder"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "order placed for purchasing the pet"
required: true
required: false
schema:
$ref: "#/definitions/Order"
responses:
@ -337,26 +265,23 @@ paths:
400:
description: "Invalid Order"
x-swagger-router-controller: "Store"
/store/order/{orderId}:
/stores/order/{orderId}:
get:
tags:
- "store"
summary: "Find purchase order by ID"
description: "For valid response try integer IDs with value >= 1 and <= 10.\n\
Other values will generated exceptions\n"
description: "For valid response try integer IDs with value <= 5 or > 10. Other\
\ values will generated exceptions"
operationId: "getOrderById"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "orderId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
maximum: 10
minimum: 1
format: "int64"
type: "string"
responses:
200:
description: "successful operation"
@ -371,27 +296,25 @@ paths:
tags:
- "store"
summary: "Delete purchase order by ID"
description: "For valid response try integer IDs with positive integer value.\\\
\ \\ Negative or non-integer values will generate API errors"
description: "For valid response try integer IDs with value < 1000. Anything\
\ above 1000 or nonintegers will generate API errors"
operationId: "deleteOrder"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "orderId"
in: "path"
description: "ID of the order that needs to be deleted"
required: true
type: "integer"
minimum: 1
format: "int64"
type: "string"
responses:
400:
description: "Invalid ID supplied"
404:
description: "Order not found"
x-swagger-router-controller: "Store"
/user:
/users:
post:
tags:
- "user"
@ -399,33 +322,34 @@ paths:
description: "This can only be done by the logged in user."
operationId: "createUser"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Created user object"
required: true
required: false
schema:
$ref: "#/definitions/User"
responses:
default:
description: "successful operation"
x-swagger-router-controller: "User"
/user/createWithArray:
/users/createWithArray:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithArrayInput"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
required: false
schema:
type: "array"
items:
@ -434,20 +358,21 @@ paths:
default:
description: "successful operation"
x-swagger-router-controller: "User"
/user/createWithList:
/users/createWithList:
post:
tags:
- "user"
summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithListInput"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "List of user object"
required: true
required: false
schema:
type: "array"
items:
@ -456,67 +381,60 @@ paths:
default:
description: "successful operation"
x-swagger-router-controller: "User"
/user/login:
/users/login:
get:
tags:
- "user"
summary: "Logs user into the system"
description: ""
operationId: "loginUser"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "username"
in: "query"
description: "The user name for login"
required: true
required: false
type: "string"
- name: "password"
in: "query"
description: "The password for login in clear text"
required: true
required: false
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "string"
headers:
X-Rate-Limit:
type: "integer"
format: "int32"
description: "calls per hour allowed by the user"
X-Expires-After:
type: "string"
format: "date-time"
description: "date in UTC when token expires"
400:
description: "Invalid username/password supplied"
x-swagger-router-controller: "User"
/user/logout:
/users/logout:
get:
tags:
- "user"
summary: "Logs out current logged in user session"
description: "null"
description: ""
operationId: "logoutUser"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters: []
responses:
default:
description: "successful operation"
x-swagger-router-controller: "User"
/user/{username}:
/users/{username}:
get:
tags:
- "user"
summary: "Get user by user name"
description: ""
operationId: "getUserByName"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "username"
in: "path"
@ -540,18 +458,18 @@ paths:
description: "This can only be done by the logged in user."
operationId: "updateUser"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "username"
in: "path"
description: "name that need to be updated"
description: "name that need to be deleted"
required: true
type: "string"
- in: "body"
name: "body"
description: "Updated user object"
required: true
required: false
schema:
$ref: "#/definitions/User"
responses:
@ -567,8 +485,8 @@ paths:
description: "This can only be done by the logged in user."
operationId: "deleteUser"
produces:
- "application/xml"
- "application/json"
- "application/xml"
parameters:
- name: "username"
in: "path"
@ -588,39 +506,12 @@ securityDefinitions:
in: "header"
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
write_pets: "modify pets in your account"
read_pets: "read your pets"
definitions:
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
xml:
name: "Order"
User:
type: "object"
properties:
@ -643,8 +534,6 @@ definitions:
type: "integer"
format: "int32"
description: "User Status"
xml:
name: "User"
Category:
type: "object"
properties:
@ -653,18 +542,6 @@ definitions:
format: "int64"
name:
type: "string"
xml:
name: "Category"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Pet:
type: "object"
required:
@ -681,37 +558,40 @@ definitions:
example: "doggie"
photoUrls:
type: "array"
xml:
name: "photoUrl"
wrapped: true
items:
type: "string"
tags:
type: "array"
xml:
name: "tag"
wrapped: true
items:
$ref: "#/definitions/Tag"
status:
type: "string"
description: "pet status in the store"
enum:
- "available"
- "pending"
- "sold"
xml:
name: "Pet"
ApiResponse:
Tag:
type: "object"
properties:
code:
id:
type: "integer"
format: "int64"
name:
type: "string"
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
type:
shipDate:
type: "string"
message:
format: "date-time"
status:
type: "string"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
description: "Order Status"
complete:
type: "boolean"

View File

@ -33,7 +33,3 @@ module.exports.updatePet = function updatePet (req, res, next) {
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
Pet.updatePetWithForm(req.swagger.params, res, next);
};
module.exports.uploadFile = function uploadFile (req, res, next) {
Pet.uploadFile(req.swagger.params, res, next);
};

View File

@ -6,20 +6,16 @@ exports.addPet = function(args, res, next) {
* body (Pet)
**/
// no response value expected for this operation
res.end();
}
exports.deletePet = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
* apiKey (String)
* petId (Long)
**/
// no response value expected for this operation
res.end();
}
@ -28,9 +24,7 @@ exports.findPetsByStatus = function(args, res, next) {
* parameters expected in the args:
* status (List)
**/
var examples = {};
var examples = {};
examples['application/json'] = [ {
"tags" : [ {
"id" : 123456789,
@ -45,7 +39,6 @@ exports.findPetsByStatus = function(args, res, next) {
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ];
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -54,7 +47,6 @@ exports.findPetsByStatus = function(args, res, next) {
res.end();
}
}
exports.findPetsByTags = function(args, res, next) {
@ -62,9 +54,7 @@ exports.findPetsByTags = function(args, res, next) {
* parameters expected in the args:
* tags (List)
**/
var examples = {};
var examples = {};
examples['application/json'] = [ {
"tags" : [ {
"id" : 123456789,
@ -79,7 +69,6 @@ exports.findPetsByTags = function(args, res, next) {
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ];
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -88,7 +77,6 @@ exports.findPetsByTags = function(args, res, next) {
res.end();
}
}
exports.getPetById = function(args, res, next) {
@ -96,9 +84,7 @@ exports.getPetById = function(args, res, next) {
* parameters expected in the args:
* petId (Long)
**/
var examples = {};
var examples = {};
examples['application/json'] = {
"tags" : [ {
"id" : 123456789,
@ -113,7 +99,6 @@ exports.getPetById = function(args, res, next) {
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -122,7 +107,6 @@ exports.getPetById = function(args, res, next) {
res.end();
}
}
exports.updatePet = function(args, res, next) {
@ -131,48 +115,17 @@ exports.updatePet = function(args, res, next) {
* body (Pet)
**/
// no response value expected for this operation
res.end();
}
exports.updatePetWithForm = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
* petId (String)
* name (String)
* status (String)
**/
// no response value expected for this operation
res.end();
}
exports.uploadFile = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
* additionalMetadata (String)
* file (file)
**/
var examples = {};
examples['application/json'] = {
"message" : "aeiou",
"code" : 123,
"type" : "aeiou"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}

View File

@ -10,10 +10,6 @@ module.exports.deleteOrder = function deleteOrder (req, res, next) {
Store.deleteOrder(req.swagger.params, res, next);
};
module.exports.getInventory = function getInventory (req, res, next) {
Store.getInventory(req.swagger.params, res, next);
};
module.exports.getOrderById = function getOrderById (req, res, next) {
Store.getOrderById(req.swagger.params, res, next);
};

View File

@ -3,44 +3,18 @@
exports.deleteOrder = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (Long)
* orderId (String)
**/
// no response value expected for this operation
res.end();
}
exports.getInventory = function(args, res, next) {
/**
* parameters expected in the args:
**/
var examples = {};
examples['application/json'] = {
"key" : 123
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}
exports.getOrderById = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (Long)
* orderId (String)
**/
var examples = {};
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
@ -49,7 +23,6 @@ exports.getOrderById = function(args, res, next) {
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -58,7 +31,6 @@ exports.getOrderById = function(args, res, next) {
res.end();
}
}
exports.placeOrder = function(args, res, next) {
@ -66,9 +38,7 @@ exports.placeOrder = function(args, res, next) {
* parameters expected in the args:
* body (Order)
**/
var examples = {};
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
@ -77,7 +47,6 @@ exports.placeOrder = function(args, res, next) {
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -86,6 +55,5 @@ exports.placeOrder = function(args, res, next) {
res.end();
}
}

View File

@ -6,8 +6,6 @@ exports.createUser = function(args, res, next) {
* body (User)
**/
// no response value expected for this operation
res.end();
}
@ -17,8 +15,6 @@ exports.createUsersWithArrayInput = function(args, res, next) {
* body (List)
**/
// no response value expected for this operation
res.end();
}
@ -28,8 +24,6 @@ exports.createUsersWithListInput = function(args, res, next) {
* body (List)
**/
// no response value expected for this operation
res.end();
}
@ -39,8 +33,6 @@ exports.deleteUser = function(args, res, next) {
* username (String)
**/
// no response value expected for this operation
res.end();
}
@ -49,9 +41,7 @@ exports.getUserByName = function(args, res, next) {
* parameters expected in the args:
* username (String)
**/
var examples = {};
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"lastName" : "aeiou",
@ -62,7 +52,6 @@ exports.getUserByName = function(args, res, next) {
"firstName" : "aeiou",
"password" : "aeiou"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -71,7 +60,6 @@ exports.getUserByName = function(args, res, next) {
res.end();
}
}
exports.loginUser = function(args, res, next) {
@ -80,11 +68,8 @@ exports.loginUser = function(args, res, next) {
* username (String)
* password (String)
**/
var examples = {};
var examples = {};
examples['application/json'] = "aeiou";
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -93,7 +78,6 @@ exports.loginUser = function(args, res, next) {
res.end();
}
}
exports.logoutUser = function(args, res, next) {
@ -101,8 +85,6 @@ exports.logoutUser = function(args, res, next) {
* parameters expected in the args:
**/
// no response value expected for this operation
res.end();
}
@ -113,8 +95,6 @@ exports.updateUser = function(args, res, next) {
* body (User)
**/
// no response value expected for this operation
res.end();
}

View File

@ -1,7 +1,7 @@
{
"name": "swagger-petstore",
"version": "1.0.0",
"description": "This is a sample server Petstore server. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n",
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"main": "index.js",
"keywords": [
"swagger"