add back summary and description to nodejs swagger.json

This commit is contained in:
wing328 2015-07-09 14:05:08 +08:00
parent 4143e28637
commit 1f35f58841
10 changed files with 1250 additions and 937 deletions

View File

@ -15,17 +15,17 @@
{{#operation}} {{#operation}}
"{{{path}}}": { "{{{path}}}": {
"{{httpMethod}}": { "{{httpMethod}}": {
"summary": "{{summary}}",
"description":"{{notes}}",
"x-swagger-router-controller": "{{classname}}", "x-swagger-router-controller": "{{classname}}",
"tags": ["{{baseName}}"], "tags": ["{{baseName}}"],
"operationId": "{{operationId}}",{{#hasParams}} "operationId": "{{operationId}}",{{#hasParams}}
"parameters": [ "parameters": [
{{#allParams}} {{#allParams}}{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
{{/allParams}} {{/allParams}}
],{{/hasParams}} ],{{/hasParams}}
"responses": { "responses": {
{{#responses}} {{#responses}}"{{code}}": {{{jsonSchema}}}
"{{code}}": {{{jsonSchema}}}
{{#hasMore}},{{/hasMore}} {{#hasMore}},{{/hasMore}}
{{/responses}} {{/responses}}
} }

View File

@ -2,21 +2,20 @@
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"title": "Swagger Petstore", "title": "Swagger Petstore",
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters", "description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0" "version": "1.0.0"
}, },
"produces": [ "produces": ["application/json"],
"application/json"
],
"host": "localhost:8080", "host": "localhost:8080",
"basePath": "/v2", "basePath": "/v2",
"paths": { "paths": {
"/user": { "/user": {
"post": { "post": {
"summary": "Create user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "createUser", "operationId": "createUser",
"parameters": [ "parameters": [
{ {
@ -28,20 +27,24 @@
"$ref" : "#/definitions/User" "$ref" : "#/definitions/User"
} }
} }
], ],
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
} }
} }
} }
} , } ,
"/user/createWithArray": { "/user/createWithArray": {
"post": { "post": {
"summary": "Creates list of users with given input array",
"description":"",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "createUsersWithArrayInput", "operationId": "createUsersWithArrayInput",
"parameters": [ "parameters": [
{ {
@ -56,20 +59,24 @@
} }
} }
} }
], ],
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
} }
} }
} }
} , } ,
"/user/createWithList": { "/user/createWithList": {
"post": { "post": {
"summary": "Creates list of users with given input array",
"description":"",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "createUsersWithListInput", "operationId": "createUsersWithListInput",
"parameters": [ "parameters": [
{ {
@ -84,20 +91,24 @@
} }
} }
} }
], ],
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
} }
} }
} }
} , } ,
"/user/login": { "/user/login": {
"get": { "get": {
"summary": "Logs user into the system",
"description":"",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "loginUser", "operationId": "loginUser",
"parameters": [ "parameters": [
{ {
@ -114,6 +125,7 @@
"required" : false, "required" : false,
"type" : "string" "type" : "string"
} }
], ],
"responses": { "responses": {
"200": { "200": {
@ -121,33 +133,130 @@
"schema" : { "schema" : {
"type" : "string" "type" : "string"
} }
}, }
,
"400": { "400": {
"description" : "Invalid username/password supplied" "description" : "Invalid username/password supplied"
} }
} }
} }
} , } ,
"/user/logout": { "/user/logout": {
"get": { "get": {
"summary": "Logs out current logged in user session",
"description":"",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "logoutUser", "operationId": "logoutUser",
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
} }
} }
} }
} , } ,
"/user/{username}": {
"get": {
"summary": "Get user by user name",
"description":"",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "getUserByName",
"parameters": [
{
"name" : "username",
"in" : "path",
"description" : "The name that needs to be fetched. Use user1 for testing. ",
"required" : true,
"type" : "string"
}
],
"responses": {
"404": {
"description" : "User not found"
}
,
"200": {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/User"
},
"examples" : {
"application/json" : {
"id" : 1,
"username" : "johnp",
"firstName" : "John",
"lastName" : "Public",
"email" : "johnp@swagger.io",
"password" : "-secret-",
"phone" : "0123456789",
"userStatus" : 0
}
}
}
,
"400": {
"description" : "Invalid username supplied"
}
}
}
} ,
"/user/{username}": {
"put": {
"summary": "Updated user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "updateUser",
"parameters": [
{
"name" : "username",
"in" : "path",
"description" : "name that need to be deleted",
"required" : true,
"type" : "string"
},
{
"in" : "body",
"name" : "body",
"description" : "Updated user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
}
],
"responses": {
"404": {
"description" : "User not found"
}
,
"400": {
"description" : "Invalid user supplied"
}
}
}
} ,
"/user/{username}": { "/user/{username}": {
"delete": { "delete": {
"summary": "Delete user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": [ "tags": ["User"],
"User"
],
"operationId": "deleteUser", "operationId": "deleteUser",
"parameters": [ "parameters": [
{ {
@ -157,23 +266,67 @@
"required" : true, "required" : true,
"type" : "string" "type" : "string"
} }
], ],
"responses": { "responses": {
"404": { "404": {
"description" : "User not found" "description" : "User not found"
}, }
,
"400": { "400": {
"description" : "Invalid username supplied" "description" : "Invalid username supplied"
} }
}
}
}
,
"/pet": {
"put": {
"summary": "Update an existing pet",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": ["Pet"],
"operationId": "updatePet",
"parameters": [
{
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description" : "Validation exception"
}
,
"404": {
"description" : "Pet not found"
}
,
"400": {
"description" : "Invalid ID supplied"
}
} }
} }
} , } ,
"/pet": { "/pet": {
"post": { "post": {
"summary": "Add a new pet to the store",
"description":"",
"x-swagger-router-controller": "Pet", "x-swagger-router-controller": "Pet",
"tags": [ "tags": ["Pet"],
"Pet"
],
"operationId": "addPet", "operationId": "addPet",
"parameters": [ "parameters": [
{ {
@ -185,20 +338,24 @@
"$ref" : "#/definitions/Pet" "$ref" : "#/definitions/Pet"
} }
} }
], ],
"responses": { "responses": {
"405": { "405": {
"description" : "Invalid input" "description" : "Invalid input"
} }
} }
} }
} , } ,
"/pet/findByStatus": { "/pet/findByStatus": {
"get": { "get": {
"summary": "Finds Pets by status",
"description":"Multiple status values can be provided with comma seperated strings",
"x-swagger-router-controller": "Pet", "x-swagger-router-controller": "Pet",
"tags": [ "tags": ["Pet"],
"Pet"
],
"operationId": "findPetsByStatus", "operationId": "findPetsByStatus",
"parameters": [ "parameters": [
{ {
@ -213,6 +370,7 @@
"collectionFormat" : "multi", "collectionFormat" : "multi",
"default" : "available" "default" : "available"
} }
], ],
"responses": { "responses": {
"200": { "200": {
@ -223,19 +381,23 @@
"$ref" : "#/definitions/Pet" "$ref" : "#/definitions/Pet"
} }
} }
}, }
,
"400": { "400": {
"description" : "Invalid status value" "description" : "Invalid status value"
} }
} }
} }
} , } ,
"/pet/findByTags": { "/pet/findByTags": {
"get": { "get": {
"summary": "Finds Pets by tags",
"description":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
"x-swagger-router-controller": "Pet", "x-swagger-router-controller": "Pet",
"tags": [ "tags": ["Pet"],
"Pet"
],
"operationId": "findPetsByTags", "operationId": "findPetsByTags",
"parameters": [ "parameters": [
{ {
@ -249,6 +411,7 @@
}, },
"collectionFormat" : "multi" "collectionFormat" : "multi"
} }
], ],
"responses": { "responses": {
"200": { "200": {
@ -259,19 +422,103 @@
"$ref" : "#/definitions/Pet" "$ref" : "#/definitions/Pet"
} }
} }
}, }
,
"400": { "400": {
"description" : "Invalid tag value" "description" : "Invalid tag value"
} }
} }
} }
} , } ,
"/pet/{petId}": {
"get": {
"summary": "Find pet by ID",
"description":"Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
"x-swagger-router-controller": "Pet",
"tags": ["Pet"],
"operationId": "getPetById",
"parameters": [
{
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"format" : "int64"
}
],
"responses": {
"404": {
"description" : "Pet not found"
}
,
"200": {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Pet"
}
}
,
"400": {
"description" : "Invalid ID supplied"
}
}
}
} ,
"/pet/{petId}": {
"post": {
"summary": "Updates a pet in the store with form data",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": ["Pet"],
"operationId": "updatePetWithForm",
"parameters": [
{
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "string"
},
{
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
},
{
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"type" : "string"
}
],
"responses": {
"405": {
"description" : "Invalid input"
}
}
}
} ,
"/pet/{petId}": { "/pet/{petId}": {
"delete": { "delete": {
"summary": "Deletes a pet",
"description":"",
"x-swagger-router-controller": "Pet", "x-swagger-router-controller": "Pet",
"tags": [ "tags": ["Pet"],
"Pet"
],
"operationId": "deletePet", "operationId": "deletePet",
"parameters": [ "parameters": [
{ {
@ -289,20 +536,24 @@
"type" : "integer", "type" : "integer",
"format" : "int64" "format" : "int64"
} }
], ],
"responses": { "responses": {
"400": { "400": {
"description" : "Invalid pet value" "description" : "Invalid pet value"
} }
} }
} }
} , } ,
"/pet/{petId}/uploadImage": { "/pet/{petId}/uploadImage": {
"post": { "post": {
"summary": "uploads an image",
"description":"",
"x-swagger-router-controller": "Pet", "x-swagger-router-controller": "Pet",
"tags": [ "tags": ["Pet"],
"Pet"
],
"operationId": "uploadFile", "operationId": "uploadFile",
"parameters": [ "parameters": [
{ {
@ -327,20 +578,26 @@
"required" : false, "required" : false,
"type" : "file" "type" : "file"
} }
], ],
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
} }
} }
} }
}, }
,
"/store/inventory": { "/store/inventory": {
"get": { "get": {
"summary": "Returns pet inventories by status",
"description":"Returns a map of status codes to quantities",
"x-swagger-router-controller": "Store", "x-swagger-router-controller": "Store",
"tags": [ "tags": ["Store"],
"Store"
],
"operationId": "getInventory", "operationId": "getInventory",
"responses": { "responses": {
"200": { "200": {
@ -353,15 +610,18 @@
} }
} }
} }
} }
} }
} , } ,
"/store/order": { "/store/order": {
"post": { "post": {
"summary": "Place an order for a pet",
"description":"",
"x-swagger-router-controller": "Store", "x-swagger-router-controller": "Store",
"tags": [ "tags": ["Store"],
"Store"
],
"operationId": "placeOrder", "operationId": "placeOrder",
"parameters": [ "parameters": [
{ {
@ -373,6 +633,7 @@
"$ref" : "#/definitions/Order" "$ref" : "#/definitions/Order"
} }
} }
], ],
"responses": { "responses": {
"200": { "200": {
@ -380,19 +641,61 @@
"schema" : { "schema" : {
"$ref" : "#/definitions/Order" "$ref" : "#/definitions/Order"
} }
}, }
,
"400": { "400": {
"description" : "Invalid Order" "description" : "Invalid Order"
} }
} }
} }
} , } ,
"/store/order/{orderId}": {
"get": {
"summary": "Find purchase order by ID",
"description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
"x-swagger-router-controller": "Store",
"tags": ["Store"],
"operationId": "getOrderById",
"parameters": [
{
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "string"
}
],
"responses": {
"404": {
"description" : "Order not found"
}
,
"200": {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
}
,
"400": {
"description" : "Invalid ID supplied"
}
}
}
} ,
"/store/order/{orderId}": { "/store/order/{orderId}": {
"delete": { "delete": {
"summary": "Delete purchase order by ID",
"description":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
"x-swagger-router-controller": "Store", "x-swagger-router-controller": "Store",
"tags": [ "tags": ["Store"],
"Store"
],
"operationId": "deleteOrder", "operationId": "deleteOrder",
"parameters": [ "parameters": [
{ {
@ -402,19 +705,24 @@
"required" : true, "required" : true,
"type" : "string" "type" : "string"
} }
], ],
"responses": { "responses": {
"404": { "404": {
"description" : "Order not found" "description" : "Order not found"
}, }
,
"400": { "400": {
"description" : "Invalid ID supplied" "description" : "Invalid ID supplied"
} }
} }
} }
} }
},
"definitions": {
}, "definitions": {
"User": { "User": {
"properties" : { "properties" : {
"id" : { "id" : {
@ -448,8 +756,7 @@
"xml" : { "xml" : {
"name" : "User" "name" : "User"
} }
}, },"Category": {
"Category": {
"properties" : { "properties" : {
"id" : { "id" : {
"type" : "integer", "type" : "integer",
@ -462,12 +769,8 @@
"xml" : { "xml" : {
"name" : "Category" "name" : "Category"
} }
}, },"Pet": {
"Pet": { "required" : [ "name", "photoUrls" ],
"required": [
"name",
"photoUrls"
],
"properties" : { "properties" : {
"id" : { "id" : {
"type" : "integer", "type" : "integer",
@ -495,18 +798,13 @@
"status" : { "status" : {
"type" : "string", "type" : "string",
"description" : "pet status in the store", "description" : "pet status in the store",
"enum": [ "enum" : [ "available", "pending", "sold" ]
"available",
"pending",
"sold"
]
} }
}, },
"xml" : { "xml" : {
"name" : "Pet" "name" : "Pet"
} }
}, },"Tag": {
"Tag": {
"properties" : { "properties" : {
"id" : { "id" : {
"type" : "integer", "type" : "integer",
@ -519,8 +817,7 @@
"xml" : { "xml" : {
"name" : "Tag" "name" : "Tag"
} }
}, },"Order": {
"Order": {
"properties" : { "properties" : {
"id" : { "id" : {
"type" : "integer", "type" : "integer",
@ -541,11 +838,7 @@
"status" : { "status" : {
"type" : "string", "type" : "string",
"description" : "Order Status", "description" : "Order Status",
"enum": [ "enum" : [ "placed", "approved", "delivered" ]
"placed",
"approved",
"delivered"
]
}, },
"complete" : { "complete" : {
"type" : "boolean" "type" : "boolean"

View File

@ -93,11 +93,11 @@ module.exports.updatePetWithForm = function updatePetWithForm(req, res, next) {
}; };
module.exports.deletePet = function deletePet (req, res, next) { module.exports.deletePet = function deletePet (req, res, next) {
var api_key = req.swagger.params['api_key'].value; var apiKey = req.swagger.params['api_key'].value;
var petId = req.swagger.params['petId'].value; var petId = req.swagger.params['petId'].value;
var result = Pet.deletePet(api_key, petId); var result = Pet.deletePet(apiKey, petId);
if(typeof result !== 'undefined') { if(typeof result !== 'undefined') {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');

View File

@ -5,12 +5,14 @@ exports.updatePet = function (body) {
var examples = {}; var examples = {};
} }
exports.addPet = function(body) { exports.addPet = function(body) {
var examples = {}; var examples = {};
} }
exports.findPetsByStatus = function(status) { exports.findPetsByStatus = function(status) {
@ -32,6 +34,7 @@ exports.findPetsByStatus = function (status) {
} ]; } ];
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -56,6 +59,7 @@ exports.findPetsByTags = function (tags) {
} ]; } ];
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -80,6 +84,7 @@ exports.getPetById = function (petId) {
}; };
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -89,16 +94,19 @@ exports.updatePetWithForm = function (petId, name, status) {
var examples = {}; var examples = {};
} }
exports.deletePet = function (api_key, petId) { exports.deletePet = function(apiKey, petId) {
var examples = {}; var examples = {};
} }
exports.uploadFile = function(petId, additionalMetadata, file) { exports.uploadFile = function(petId, additionalMetadata, file) {
var examples = {}; var examples = {};
} }

View File

@ -9,6 +9,7 @@ exports.getInventory = function () {
}; };
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -23,10 +24,11 @@ exports.placeOrder = function (body) {
"complete" : true, "complete" : true,
"status" : "aeiou", "status" : "aeiou",
"quantity" : 123, "quantity" : 123,
"shipDate": "2015-03-19T21:51:51.599+0000" "shipDate" : "2015-07-09T06:03:19.571+0000"
}; };
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -41,10 +43,11 @@ exports.getOrderById = function (orderId) {
"complete" : true, "complete" : true,
"status" : "aeiou", "status" : "aeiou",
"quantity" : 123, "quantity" : 123,
"shipDate": "2015-03-19T21:51:51.603+0000" "shipDate" : "2015-07-09T06:03:19.576+0000"
}; };
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -54,4 +57,5 @@ exports.deleteOrder = function (orderId) {
var examples = {}; var examples = {};
} }

View File

@ -5,18 +5,21 @@ exports.createUser = function (body) {
var examples = {}; var examples = {};
} }
exports.createUsersWithArrayInput = function(body) { exports.createUsersWithArrayInput = function(body) {
var examples = {}; var examples = {};
} }
exports.createUsersWithListInput = function(body) { exports.createUsersWithListInput = function(body) {
var examples = {}; var examples = {};
} }
exports.loginUser = function(username, password) { exports.loginUser = function(username, password) {
@ -25,6 +28,7 @@ exports.loginUser = function (username, password) {
examples['application/json'] = "aeiou"; examples['application/json'] = "aeiou";
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -34,23 +38,25 @@ exports.logoutUser = function () {
var examples = {}; var examples = {};
} }
exports.getUserByName = function(username) { exports.getUserByName = function(username) {
var examples = {}; var examples = {};
examples['application/json'] = { examples['application/json'] = {
"id": 123456789, "id" : 1,
"lastName": "aeiou", "username" : "johnp",
"phone": "aeiou", "firstName" : "John",
"username": "aeiou", "lastName" : "Public",
"email": "aeiou", "email" : "johnp@swagger.io",
"userStatus": 123, "password" : "-secret-",
"firstName": "aeiou", "phone" : "0123456789",
"password": "aeiou" "userStatus" : 0
}; };
if(Object.keys(examples).length > 0) if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]]; return examples[Object.keys(examples)[0]];
@ -60,10 +66,12 @@ exports.updateUser = function (username, body) {
var examples = {}; var examples = {};
} }
exports.deleteUser = function(username) { exports.deleteUser = function(username) {
var examples = {}; var examples = {};
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "", "name": "",
"version": "", "version": "1.0.0",
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters", "description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
"swagger" "swagger"