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}}
"{{{path}}}": {
"{{httpMethod}}": {
"summary": "{{summary}}",
"description":"{{notes}}",
"x-swagger-router-controller": "{{classname}}",
"tags": ["{{baseName}}"],
"operationId": "{{operationId}}",{{#hasParams}}
"parameters": [
{{#allParams}}
{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
{{#allParams}}{{{jsonSchema}}}{{#hasMore}},{{/hasMore}}
{{/allParams}}
],{{/hasParams}}
"responses": {
{{#responses}}
"{{code}}": {{{jsonSchema}}}
{{#responses}}"{{code}}": {{{jsonSchema}}}
{{#hasMore}},{{/hasMore}}
{{/responses}}
}

View File

@ -2,21 +2,20 @@
"swagger": "2.0",
"info": {
"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"
},
"produces": [
"application/json"
],
"produces": ["application/json"],
"host": "localhost:8080",
"basePath": "/v2",
"paths": {
"/user": {
"post": {
"summary": "Create user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "createUser",
"parameters": [
{
@ -28,20 +27,24 @@
"$ref" : "#/definitions/User"
}
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/createWithArray": {
"post": {
"summary": "Creates list of users with given input array",
"description":"",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "createUsersWithArrayInput",
"parameters": [
{
@ -56,20 +59,24 @@
}
}
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/createWithList": {
"post": {
"summary": "Creates list of users with given input array",
"description":"",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "createUsersWithListInput",
"parameters": [
{
@ -84,20 +91,24 @@
}
}
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/login": {
"get": {
"summary": "Logs user into the system",
"description":"",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "loginUser",
"parameters": [
{
@ -114,6 +125,7 @@
"required" : false,
"type" : "string"
}
],
"responses": {
"200": {
@ -121,33 +133,130 @@
"schema" : {
"type" : "string"
}
},
}
,
"400": {
"description" : "Invalid username/password supplied"
}
}
}
} ,
"/user/logout": {
"get": {
"summary": "Logs out current logged in user session",
"description":"",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "logoutUser",
"responses": {
"default": {
"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}": {
"delete": {
"summary": "Delete user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User",
"tags": [
"User"
],
"tags": ["User"],
"operationId": "deleteUser",
"parameters": [
{
@ -157,23 +266,67 @@
"required" : true,
"type" : "string"
}
],
"responses": {
"404": {
"description" : "User not found"
},
}
,
"400": {
"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": {
"post": {
"summary": "Add a new pet to the store",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": [
"Pet"
],
"tags": ["Pet"],
"operationId": "addPet",
"parameters": [
{
@ -185,20 +338,24 @@
"$ref" : "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description" : "Invalid input"
}
}
}
} ,
"/pet/findByStatus": {
"get": {
"summary": "Finds Pets by status",
"description":"Multiple status values can be provided with comma seperated strings",
"x-swagger-router-controller": "Pet",
"tags": [
"Pet"
],
"tags": ["Pet"],
"operationId": "findPetsByStatus",
"parameters": [
{
@ -213,6 +370,7 @@
"collectionFormat" : "multi",
"default" : "available"
}
],
"responses": {
"200": {
@ -223,19 +381,23 @@
"$ref" : "#/definitions/Pet"
}
}
},
}
,
"400": {
"description" : "Invalid status value"
}
}
}
} ,
"/pet/findByTags": {
"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",
"tags": [
"Pet"
],
"tags": ["Pet"],
"operationId": "findPetsByTags",
"parameters": [
{
@ -249,6 +411,7 @@
},
"collectionFormat" : "multi"
}
],
"responses": {
"200": {
@ -259,19 +422,103 @@
"$ref" : "#/definitions/Pet"
}
}
},
}
,
"400": {
"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}": {
"delete": {
"summary": "Deletes a pet",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": [
"Pet"
],
"tags": ["Pet"],
"operationId": "deletePet",
"parameters": [
{
@ -289,20 +536,24 @@
"type" : "integer",
"format" : "int64"
}
],
"responses": {
"400": {
"description" : "Invalid pet value"
}
}
}
} ,
"/pet/{petId}/uploadImage": {
"post": {
"summary": "uploads an image",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": [
"Pet"
],
"tags": ["Pet"],
"operationId": "uploadFile",
"parameters": [
{
@ -327,20 +578,26 @@
"required" : false,
"type" : "file"
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
},
}
,
"/store/inventory": {
"get": {
"summary": "Returns pet inventories by status",
"description":"Returns a map of status codes to quantities",
"x-swagger-router-controller": "Store",
"tags": [
"Store"
],
"tags": ["Store"],
"operationId": "getInventory",
"responses": {
"200": {
@ -353,15 +610,18 @@
}
}
}
}
}
} ,
"/store/order": {
"post": {
"summary": "Place an order for a pet",
"description":"",
"x-swagger-router-controller": "Store",
"tags": [
"Store"
],
"tags": ["Store"],
"operationId": "placeOrder",
"parameters": [
{
@ -373,6 +633,7 @@
"$ref" : "#/definitions/Order"
}
}
],
"responses": {
"200": {
@ -380,19 +641,61 @@
"schema" : {
"$ref" : "#/definitions/Order"
}
},
}
,
"400": {
"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}": {
"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",
"tags": [
"Store"
],
"tags": ["Store"],
"operationId": "deleteOrder",
"parameters": [
{
@ -402,19 +705,24 @@
"required" : true,
"type" : "string"
}
],
"responses": {
"404": {
"description" : "Order not found"
},
}
,
"400": {
"description" : "Invalid ID supplied"
}
}
}
}
},
"definitions": {
}, "definitions": {
"User": {
"properties" : {
"id" : {
@ -448,8 +756,7 @@
"xml" : {
"name" : "User"
}
},
"Category": {
},"Category": {
"properties" : {
"id" : {
"type" : "integer",
@ -462,12 +769,8 @@
"xml" : {
"name" : "Category"
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
},"Pet": {
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
@ -495,18 +798,13 @@
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum": [
"available",
"pending",
"sold"
]
"enum" : [ "available", "pending", "sold" ]
}
},
"xml" : {
"name" : "Pet"
}
},
"Tag": {
},"Tag": {
"properties" : {
"id" : {
"type" : "integer",
@ -519,8 +817,7 @@
"xml" : {
"name" : "Tag"
}
},
"Order": {
},"Order": {
"properties" : {
"id" : {
"type" : "integer",
@ -541,11 +838,7 @@
"status" : {
"type" : "string",
"description" : "Order Status",
"enum": [
"placed",
"approved",
"delivered"
]
"enum" : [ "placed", "approved", "delivered" ]
},
"complete" : {
"type" : "boolean"

View File

@ -93,11 +93,11 @@ module.exports.updatePetWithForm = function updatePetWithForm(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 result = Pet.deletePet(api_key, petId);
var result = Pet.deletePet(apiKey, petId);
if(typeof result !== 'undefined') {
res.setHeader('Content-Type', 'application/json');

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "",
"version": "",
"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",
"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",
"keywords": [
"swagger"