Merge pull request #1188 from wing328/master

[NodeJS] fixed HTML-escaped description on nodejs json files
This commit is contained in:
wing328 2015-09-05 15:44:16 +08:00
commit ee1febcd95
7 changed files with 394 additions and 373 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "{{projectName}}", "name": "{{projectName}}",
"version": "{{appVersion}}", "version": "{{appVersion}}",
"description": "{{appDescription}}", "description": "{{{appDescription}}}",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
"swagger" "swagger"

View File

@ -2,7 +2,7 @@
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"title": "{{appName}}", "title": "{{appName}}",
"description": "{{appDescription}}", "description": "{{{appDescription}}}",
"version": "{{apiVersion}}" "version": "{{apiVersion}}"
}, },
{{#apiInfo}} {{#apiInfo}}

View File

@ -2,7 +2,7 @@
"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 &lt;a href=\&quot;http://swagger.io\&quot;&gt;http://swagger.io&lt;/a&gt; or on irc.freenode.net, #swagger. For this sample, you can use the api key \&quot;special-key\&quot; 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": ["application/json"], "produces": ["application/json"],
@ -10,68 +10,8 @@
"basePath": "/v2", "basePath": "/v2",
"paths": { "paths": {
"/user": {
"post": {
"summary": "Create user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "createUser",
"parameters": [
{
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : false,
"schema" : {
"$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"],
"operationId": "createUsersWithArrayInput",
"parameters": [
{
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/createWithList": { "/user/createWithList": {
"post": { "post": {
"summary": "Creates list of users with given input array", "summary": "Creates list of users with given input array",
"description":"", "description":"",
@ -100,57 +40,33 @@
} }
} }
} , } ,
"/user/login": { "/user/createWithArray": {
"get": {
"summary": "Logs user into the system", "post": {
"summary": "Creates list of users with given input array",
"description":"", "description":"",
"x-swagger-router-controller": "User", "x-swagger-router-controller": "User",
"tags": ["User"], "tags": ["User"],
"operationId": "loginUser", "operationId": "createUsersWithArrayInput",
"parameters": [ "parameters": [
{ {
"name" : "username", "in" : "body",
"in" : "query", "name" : "body",
"description" : "The user name for login", "description" : "List of user object",
"required" : false, "required" : false,
"type" : "string" "schema" : {
}, "type" : "array",
{ "items" : {
"name" : "password", "$ref" : "#/definitions/User"
"in" : "query", }
"description" : "The password for login in clear text", }
"required" : false,
"type" : "string"
} }
], ],
"responses": {
"200": {
"description" : "successful operation",
"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"],
"operationId": "logoutUser",
"responses": { "responses": {
"default": { "default": {
"description" : "successful operation" "description" : "successful operation"
@ -158,10 +74,12 @@
} }
} }
} , } ,
"/user/{username}": { "/user/{username}": {
"get": { "get": {
"summary": "Get user by user name", "summary": "Get user by user name",
"description":"", "description":"",
@ -208,10 +126,8 @@
} }
} } ,
} ,
"/user/{username}": {
"put": { "put": {
"summary": "Updated user", "summary": "Updated user",
"description":"This can only be done by the logged in user.", "description":"This can only be done by the logged in user.",
@ -248,10 +164,8 @@
} }
} } ,
} ,
"/user/{username}": {
"delete": { "delete": {
"summary": "Delete user", "summary": "Delete user",
"description":"This can only be done by the logged in user.", "description":"This can only be done by the logged in user.",
@ -279,12 +193,106 @@
} }
} }
}
} ,
"/user": {
"post": {
"summary": "Create user",
"description":"This can only be done by the logged in user.",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "createUser",
"parameters": [
{
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : false,
"schema" : {
"$ref" : "#/definitions/User"
}
}
],
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/logout": {
"get": {
"summary": "Logs out current logged in user session",
"description":"",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "logoutUser",
"responses": {
"default": {
"description" : "successful operation"
}
}
}
} ,
"/user/login": {
"get": {
"summary": "Logs user into the system",
"description":"",
"x-swagger-router-controller": "User",
"tags": ["User"],
"operationId": "loginUser",
"parameters": [
{
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : false,
"type" : "string"
},
{
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : false,
"type" : "string"
}
],
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "string"
}
}
,
"400": {
"description" : "Invalid username/password supplied"
}
}
}
} ,
,
"/pet": { "/pet": {
"put": { "put": {
"summary": "Update an existing pet", "summary": "Update an existing pet",
"description":"", "description":"",
@ -318,10 +326,8 @@
} }
} } ,
} ,
"/pet": {
"post": { "post": {
"summary": "Add a new pet to the store", "summary": "Add a new pet to the store",
"description":"", "description":"",
@ -347,208 +353,12 @@
} }
} }
} ,
"/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"],
"operationId": "findPetsByStatus",
"parameters": [
{
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi",
"default" : "available"
}
],
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$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"],
"operationId": "findPetsByTags",
"parameters": [
{
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi"
}
],
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
}
,
"400": {
"description" : "Invalid tag value"
}
}
}
} ,
"/pet/{petId}": {
"get": {
"summary": "Find pet by ID",
"description":"Returns a pet when ID &lt; 10. ID &gt; 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"],
"operationId": "deletePet",
"parameters": [
{
"name" : "api_key",
"in" : "header",
"description" : "",
"required" : false,
"type" : "string"
},
{
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
}
],
"responses": {
"400": {
"description" : "Invalid pet value"
}
}
}
} , } ,
"/pet/{petId}/uploadImage": { "/pet/{petId}/uploadImage": {
"post": { "post": {
"summary": "uploads an image", "summary": "uploads an image",
"description":"", "description":"",
@ -587,51 +397,30 @@
} }
} }
}
,
"/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"],
"operationId": "getInventory",
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
}
}
} , } ,
"/store/order": { "/pet/findByStatus": {
"post": {
"summary": "Place an order for a pet", "get": {
"description":"", "summary": "Finds Pets by status",
"x-swagger-router-controller": "Store", "description":"Multiple status values can be provided with comma seperated strings",
"tags": ["Store"], "x-swagger-router-controller": "Pet",
"operationId": "placeOrder", "tags": ["Pet"],
"operationId": "findPetsByStatus",
"parameters": [ "parameters": [
{ {
"in" : "body", "name" : "status",
"name" : "body", "in" : "query",
"description" : "order placed for purchasing the pet", "description" : "Status values that need to be considered for filter",
"required" : false, "required" : false,
"schema" : { "type" : "array",
"$ref" : "#/definitions/Order" "items" : {
} "type" : "string"
},
"collectionFormat" : "multi",
"default" : "available"
} }
], ],
@ -639,20 +428,182 @@
"200": { "200": {
"description" : "successful operation", "description" : "successful operation",
"schema" : { "schema" : {
"$ref" : "#/definitions/Order" "type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
} }
} }
, ,
"400": { "400": {
"description" : "Invalid Order" "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"],
"operationId": "findPetsByTags",
"parameters": [
{
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : false,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "multi"
}
],
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
}
,
"400": {
"description" : "Invalid tag value"
}
}
}
} ,
"/pet/{petId}": {
"get": {
"summary": "Find pet by ID",
"description":"Returns a pet when ID &lt; 10. ID &gt; 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"
}
}
} ,
"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"
}
}
} ,
"delete": {
"summary": "Deletes a pet",
"description":"",
"x-swagger-router-controller": "Pet",
"tags": ["Pet"],
"operationId": "deletePet",
"parameters": [
{
"name" : "petId",
"in" : "path",
"description" : "Pet id to delete",
"required" : true,
"type" : "integer",
"format" : "int64"
},
{
"name" : "api_key",
"in" : "header",
"description" : "",
"required" : false,
"type" : "string"
}
],
"responses": {
"400": {
"description" : "Invalid pet value"
}
}
}
} ,
"/store/order/{orderId}": { "/store/order/{orderId}": {
"get": { "get": {
"summary": "Find purchase order by ID", "summary": "Find purchase order by ID",
"description":"For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions", "description":"For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions",
@ -687,10 +638,8 @@
} }
} } ,
} ,
"/store/order/{orderId}": {
"delete": { "delete": {
"summary": "Delete purchase order by ID", "summary": "Delete purchase order by ID",
"description":"For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors", "description":"For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors",
@ -718,10 +667,74 @@
} }
}
} ,
"/store/order": {
"post": {
"summary": "Place an order for a pet",
"description":"",
"x-swagger-router-controller": "Store",
"tags": ["Store"],
"operationId": "placeOrder",
"parameters": [
{
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : false,
"schema" : {
"$ref" : "#/definitions/Order"
}
}
],
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
}
,
"400": {
"description" : "Invalid Order"
}
}
}
} ,
"/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"],
"operationId": "getInventory",
"responses": {
"200": {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
} }
}
}
}
}
} }
}, "definitions": { }, "definitions": {
"User": { "User": {
"properties" : { "properties" : {
@ -785,12 +798,20 @@
}, },
"photoUrls" : { "photoUrls" : {
"type" : "array", "type" : "array",
"xml" : {
"name" : "photoUrl",
"wrapped" : true
},
"items" : { "items" : {
"type" : "string" "type" : "string"
} }
}, },
"tags" : { "tags" : {
"type" : "array", "type" : "array",
"xml" : {
"name" : "tag",
"wrapped" : true
},
"items" : { "items" : {
"$ref" : "#/definitions/Tag" "$ref" : "#/definitions/Tag"
} }

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 apiKey = req.swagger.params['api_key'].value;
var petId = req.swagger.params['petId'].value; var petId = req.swagger.params['petId'].value;
var apiKey = req.swagger.params['api_key'].value;
var result = Pet.deletePet(apiKey, petId); var result = Pet.deletePet(petId, apiKey);
if(typeof result !== 'undefined') { if(typeof result !== 'undefined') {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');

View File

@ -96,7 +96,7 @@ exports.updatePetWithForm = function(petId, name, status) {
} }
exports.deletePet = function(apiKey, petId) { exports.deletePet = function(petId, apiKey) {
var examples = {}; var examples = {};

View File

@ -24,7 +24,7 @@ exports.placeOrder = function(body) {
"complete" : true, "complete" : true,
"status" : "aeiou", "status" : "aeiou",
"quantity" : 123, "quantity" : 123,
"shipDate" : "2015-07-09T06:03:19.571+0000" "shipDate" : "2015-09-03T14:34:08.343+0000"
}; };
@ -43,7 +43,7 @@ exports.getOrderById = function(orderId) {
"complete" : true, "complete" : true,
"status" : "aeiou", "status" : "aeiou",
"quantity" : 123, "quantity" : 123,
"shipDate" : "2015-07-09T06:03:19.576+0000" "shipDate" : "2015-09-03T14:34:08.347+0000"
}; };

View File

@ -1,7 +1,7 @@
{ {
"name": "", "name": "",
"version": "1.0.0", "version": "1.0.0",
"description": "This is a sample server Petstore server. You can find out more about Swagger at &lt;a href=\&quot;http://swagger.io\&quot;&gt;http://swagger.io&lt;/a&gt; or on irc.freenode.net, #swagger. For this sample, you can use the api key \&quot;special-key\&quot; 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"