diff --git a/modules/swagger-codegen/src/main/resources/nodejs/package.mustache b/modules/swagger-codegen/src/main/resources/nodejs/package.mustache
index 7add6e813fe..89db4c0b91e 100644
--- a/modules/swagger-codegen/src/main/resources/nodejs/package.mustache
+++ b/modules/swagger-codegen/src/main/resources/nodejs/package.mustache
@@ -1,7 +1,7 @@
{
"name": "{{projectName}}",
"version": "{{appVersion}}",
- "description": "{{appDescription}}",
+ "description": "{{{appDescription}}}",
"main": "index.js",
"keywords": [
"swagger"
diff --git a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache
index 3b975e53b80..1d0f7d78162 100644
--- a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache
+++ b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache
@@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"title": "{{appName}}",
- "description": "{{appDescription}}",
+ "description": "{{{appDescription}}}",
"version": "{{apiVersion}}"
},
{{#apiInfo}}
diff --git a/samples/server/petstore/nodejs/api/swagger.json b/samples/server/petstore/nodejs/api/swagger.json
index 02c5ca0f97f..4f091973cf2 100644
--- a/samples/server/petstore/nodejs/api/swagger.json
+++ b/samples/server/petstore/nodejs/api/swagger.json
@@ -2,7 +2,7 @@
"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 http://swagger.io 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"],
@@ -10,68 +10,8 @@
"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"],
- "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": {
+
"post": {
"summary": "Creates list of users with given input array",
"description":"",
@@ -100,57 +40,33 @@
}
- }
+ }
+
} ,
- "/user/login": {
- "get": {
- "summary": "Logs user into the system",
+ "/user/createWithArray": {
+
+ "post": {
+ "summary": "Creates list of users with given input array",
"description":"",
"x-swagger-router-controller": "User",
"tags": ["User"],
- "operationId": "loginUser",
+ "operationId": "createUsersWithArrayInput",
"parameters": [
{
- "name" : "username",
- "in" : "query",
- "description" : "The user name for login",
+ "in" : "body",
+ "name" : "body",
+ "description" : "List of user object",
"required" : false,
- "type" : "string"
-},
- {
- "name" : "password",
- "in" : "query",
- "description" : "The password for login in clear text",
- "required" : false,
- "type" : "string"
+ "schema" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/definitions/User"
+ }
+ }
}
],
- "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": {
"default": {
"description" : "successful operation"
@@ -158,10 +74,12 @@
}
- }
+ }
+
} ,
"/user/{username}": {
+
"get": {
"summary": "Get user by user name",
"description":"",
@@ -208,10 +126,8 @@
}
- }
- } ,
-
- "/user/{username}": {
+ } ,
+
"put": {
"summary": "Updated user",
"description":"This can only be done by the logged in user.",
@@ -248,10 +164,8 @@
}
- }
- } ,
-
- "/user/{username}": {
+ } ,
+
"delete": {
"summary": "Delete 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": {
+
"put": {
"summary": "Update an existing pet",
"description":"",
@@ -318,10 +326,8 @@
}
- }
- } ,
-
- "/pet": {
+ } ,
+
"post": {
"summary": "Add a new pet to the store",
"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 < 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"],
- "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": {
+
"post": {
"summary": "uploads an image",
"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": {
- "post": {
- "summary": "Place an order for a pet",
- "description":"",
- "x-swagger-router-controller": "Store",
- "tags": ["Store"],
- "operationId": "placeOrder",
+ "/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": [
{
- "in" : "body",
- "name" : "body",
- "description" : "order placed for purchasing the pet",
+ "name" : "status",
+ "in" : "query",
+ "description" : "Status values that need to be considered for filter",
"required" : false,
- "schema" : {
- "$ref" : "#/definitions/Order"
- }
+ "type" : "array",
+ "items" : {
+ "type" : "string"
+ },
+ "collectionFormat" : "multi",
+ "default" : "available"
}
],
@@ -639,20 +428,182 @@
"200": {
"description" : "successful operation",
"schema" : {
- "$ref" : "#/definitions/Order"
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/definitions/Pet"
+ }
}
}
,
"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 < 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"
+}
+
+
+ }
+ } ,
+
+ "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}": {
+
"get": {
"summary": "Find purchase order by ID",
"description":"For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
@@ -687,10 +638,8 @@
}
- }
- } ,
-
- "/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",
@@ -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": {
"User": {
"properties" : {
@@ -785,12 +798,20 @@
},
"photoUrls" : {
"type" : "array",
+ "xml" : {
+ "name" : "photoUrl",
+ "wrapped" : true
+ },
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
+ "xml" : {
+ "name" : "tag",
+ "wrapped" : true
+ },
"items" : {
"$ref" : "#/definitions/Tag"
}
diff --git a/samples/server/petstore/nodejs/controllers/Pet.js b/samples/server/petstore/nodejs/controllers/Pet.js
index f23f593f414..a268c8fa700 100644
--- a/samples/server/petstore/nodejs/controllers/Pet.js
+++ b/samples/server/petstore/nodejs/controllers/Pet.js
@@ -93,11 +93,11 @@ module.exports.updatePetWithForm = function updatePetWithForm (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 apiKey = req.swagger.params['api_key'].value;
- var result = Pet.deletePet(apiKey, petId);
+ var result = Pet.deletePet(petId, apiKey);
if(typeof result !== 'undefined') {
res.setHeader('Content-Type', 'application/json');
diff --git a/samples/server/petstore/nodejs/controllers/PetService.js b/samples/server/petstore/nodejs/controllers/PetService.js
index cdfac3466ae..f238fa410ac 100644
--- a/samples/server/petstore/nodejs/controllers/PetService.js
+++ b/samples/server/petstore/nodejs/controllers/PetService.js
@@ -96,7 +96,7 @@ exports.updatePetWithForm = function(petId, name, status) {
}
-exports.deletePet = function(apiKey, petId) {
+exports.deletePet = function(petId, apiKey) {
var examples = {};
diff --git a/samples/server/petstore/nodejs/controllers/StoreService.js b/samples/server/petstore/nodejs/controllers/StoreService.js
index ba9ffd4fc44..947774aad2e 100644
--- a/samples/server/petstore/nodejs/controllers/StoreService.js
+++ b/samples/server/petstore/nodejs/controllers/StoreService.js
@@ -24,7 +24,7 @@ exports.placeOrder = function(body) {
"complete" : true,
"status" : "aeiou",
"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,
"status" : "aeiou",
"quantity" : 123,
- "shipDate" : "2015-07-09T06:03:19.576+0000"
+ "shipDate" : "2015-09-03T14:34:08.347+0000"
};
diff --git a/samples/server/petstore/nodejs/package.json b/samples/server/petstore/nodejs/package.json
index 7bb6df08fb5..35390feefda 100644
--- a/samples/server/petstore/nodejs/package.json
+++ b/samples/server/petstore/nodejs/package.json
@@ -1,7 +1,7 @@
{
"name": "",
"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 http://swagger.io 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"