Fix nodejs-server path issue in windows platform (#7808)

* fix nodejs-server path issue in windows platform

* only replace character in apiPackage
This commit is contained in:
William Cheng 2018-03-12 23:21:07 +08:00 committed by GitHub
parent 1bb1e44d18
commit e7f4fb3c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 118 additions and 34 deletions

View File

@ -3324,7 +3324,7 @@ public class DefaultCodegen {
public String apiFilename(String templateName, String tag) { public String apiFilename(String templateName, String tag) {
String suffix = apiTemplateFiles().get(templateName); String suffix = apiTemplateFiles().get(templateName);
return apiFileFolder() + '/' + toApiFilename(tag) + suffix; return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
} }
/** /**
@ -3337,7 +3337,7 @@ public class DefaultCodegen {
*/ */
public String apiDocFilename(String templateName, String tag) { public String apiDocFilename(String templateName, String tag) {
String suffix = apiDocTemplateFiles().get(templateName); String suffix = apiDocTemplateFiles().get(templateName);
return apiDocFileFolder() + '/' + toApiDocFilename(tag) + suffix; return apiDocFileFolder() + File.separator + toApiDocFilename(tag) + suffix;
} }
/** /**
@ -3350,7 +3350,7 @@ public class DefaultCodegen {
*/ */
public String apiTestFilename(String templateName, String tag) { public String apiTestFilename(String templateName, String tag) {
String suffix = apiTestTemplateFiles().get(templateName); String suffix = apiTestTemplateFiles().get(templateName);
return apiTestFileFolder() + '/' + toApiTestFilename(tag) + suffix; return apiTestFileFolder() + File.separator + toApiTestFilename(tag) + suffix;
} }
public boolean shouldOverwrite(String filename) { public boolean shouldOverwrite(String filename) {

View File

@ -85,7 +85,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
additionalProperties.put("serverPort", serverPort); additionalProperties.put("serverPort", serverPort);
additionalProperties.put("implFolder", implFolder); additionalProperties.put("implFolder", implFolder);
supportingFiles.add(new SupportingFile("writer.mustache", ("utils").replace(".", "/"), "writer.js")); supportingFiles.add(new SupportingFile("writer.mustache", ("utils").replace(".", File.separator), "writer.js"));
cliOptions.add(CliOption.newBoolean(GOOGLE_CLOUD_FUNCTIONS, cliOptions.add(CliOption.newBoolean(GOOGLE_CLOUD_FUNCTIONS,
"When specified, it will generate the code which runs within Google Cloud Functions " "When specified, it will generate the code which runs within Google Cloud Functions "
@ -164,7 +164,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
} }
private String implFileFolder(String output) { private String implFileFolder(String output) {
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/'); return outputFolder + File.separator + output + File.separator + apiPackage().replace('.', File.separatorChar);
} }
/** /**

View File

@ -13,6 +13,7 @@ info:
license: license:
name: "Apache-2.0" name: "Apache-2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2" basePath: "/v2"
tags: tags:
- name: "pet" - name: "pet"
@ -524,7 +525,7 @@ paths:
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
description: "The name that needs to be fetched. Use user1 for testing. " description: "The name that needs to be fetched. Use user1 for testing."
required: true required: true
type: "string" type: "string"
responses: responses:

View File

@ -61,7 +61,7 @@ exports.deleteUser = function(username) {
* Get user by user name * Get user by user name
* *
* *
* username String The name that needs to be fetched. Use user1 for testing. * username String The name that needs to be fetched. Use user1 for testing.
* returns User * returns User
**/ **/
exports.getUserByName = function(username) { exports.getUserByName = function(username) {

View File

@ -1 +1 @@
2.2.3-SNAPSHOT 2.4.0-SNAPSHOT

View File

@ -11,7 +11,7 @@ info:
contact: contact:
email: "apiteam@swagger.io" email: "apiteam@swagger.io"
license: license:
name: "Apache 2.0" name: "Apache-2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io" host: "petstore.swagger.io"
basePath: "/v2" basePath: "/v2"
@ -108,11 +108,11 @@ paths:
type: "array" type: "array"
items: items:
type: "string" type: "string"
default: "available"
enum: enum:
- "available" - "available"
- "pending" - "pending"
- "sold" - "sold"
default: "available"
collectionFormat: "csv" collectionFormat: "csv"
responses: responses:
200: 200:
@ -161,6 +161,7 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
deprecated: true
x-swagger-router-controller: "Pet" x-swagger-router-controller: "Pet"
/pet/{petId}: /pet/{petId}:
get: get:
@ -524,7 +525,7 @@ paths:
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
description: "The name that needs to be fetched. Use user1 for testing. " description: "The name that needs to be fetched. Use user1 for testing."
required: true required: true
type: "string" type: "string"
responses: responses:
@ -625,6 +626,13 @@ definitions:
default: false default: false
title: "Pet Order" title: "Pet Order"
description: "An order for a pets from the pet store" description: "An order for a pets from the pet store"
example:
petId: 6
quantity: 1
id: 0
shipDate: "2000-01-23T04:56:07.000+00:00"
complete: false
status: "placed"
xml: xml:
name: "Order" name: "Order"
Category: Category:
@ -637,6 +645,9 @@ definitions:
type: "string" type: "string"
title: "Pet category" title: "Pet category"
description: "A category for a pet" description: "A category for a pet"
example:
name: "name"
id: 6
xml: xml:
name: "Category" name: "Category"
User: User:
@ -663,6 +674,15 @@ definitions:
description: "User Status" description: "User Status"
title: "a User" title: "a User"
description: "A User who is purchasing from the pet store" description: "A User who is purchasing from the pet store"
example:
firstName: "firstName"
lastName: "lastName"
password: "password"
userStatus: 6
phone: "phone"
id: 0
email: "email"
username: "username"
xml: xml:
name: "User" name: "User"
Tag: Tag:
@ -675,6 +695,9 @@ definitions:
type: "string" type: "string"
title: "Pet Tag" title: "Pet Tag"
description: "A tag for a pet" description: "A tag for a pet"
example:
name: "name"
id: 1
xml: xml:
name: "Tag" name: "Tag"
Pet: Pet:
@ -714,6 +737,21 @@ definitions:
- "sold" - "sold"
title: "a Pet" title: "a Pet"
description: "A pet for sale in the pet store" description: "A pet for sale in the pet store"
example:
photoUrls:
- "photoUrls"
- "photoUrls"
name: "doggie"
id: 0
category:
name: "name"
id: 6
tags:
- name: "name"
id: 1
- name: "name"
id: 1
status: "available"
xml: xml:
name: "Pet" name: "Pet"
ApiResponse: ApiResponse:
@ -728,6 +766,10 @@ definitions:
type: "string" type: "string"
title: "An uploaded response" title: "An uploaded response"
description: "Describes the result of uploading an image resource" description: "Describes the result of uploading an image resource"
example:
code: 0
type: "type"
message: "message"
externalDocs: externalDocs:
description: "Find out more about Swagger" description: "Find out more about Swagger"
url: "http://swagger.io" url: "http://swagger.io"

View File

@ -4,8 +4,8 @@
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). 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](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prestart": "npm install", "prestart": "npm install",
"start": "node index.js" "start": "node index.js"
}, },
"keywords": [ "keywords": [
"swagger" "swagger"

View File

@ -41,15 +41,34 @@ exports.findPetsByStatus = function(status) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var examples = {}; var examples = {};
examples['application/json'] = [ { examples['application/json'] = [ {
"photoUrls" : [ "aeiou" ], "photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie", "name" : "doggie",
"id" : 0, "id" : 0,
"category" : { "category" : {
"name" : "aeiou", "name" : "name",
"id" : 6 "id" : 6
}, },
"tags" : [ { "tags" : [ {
"name" : "aeiou", "name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}, {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1 "id" : 1
} ], } ],
"status" : "available" "status" : "available"
@ -74,15 +93,34 @@ exports.findPetsByTags = function(tags) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var examples = {}; var examples = {};
examples['application/json'] = [ { examples['application/json'] = [ {
"photoUrls" : [ "aeiou" ], "photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie", "name" : "doggie",
"id" : 0, "id" : 0,
"category" : { "category" : {
"name" : "aeiou", "name" : "name",
"id" : 6 "id" : 6
}, },
"tags" : [ { "tags" : [ {
"name" : "aeiou", "name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}, {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1 "id" : 1
} ], } ],
"status" : "available" "status" : "available"
@ -107,15 +145,18 @@ exports.getPetById = function(petId) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var examples = {}; var examples = {};
examples['application/json'] = { examples['application/json'] = {
"photoUrls" : [ "aeiou" ], "photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie", "name" : "doggie",
"id" : 0, "id" : 0,
"category" : { "category" : {
"name" : "aeiou", "name" : "name",
"id" : 6 "id" : 6
}, },
"tags" : [ { "tags" : [ {
"name" : "aeiou", "name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1 "id" : 1
} ], } ],
"status" : "available" "status" : "available"
@ -173,8 +214,8 @@ exports.uploadFile = function(petId,additionalMetadata,file) {
var examples = {}; var examples = {};
examples['application/json'] = { examples['application/json'] = {
"code" : 0, "code" : 0,
"type" : "aeiou", "type" : "type",
"message" : "aeiou" "message" : "message"
}; };
if (Object.keys(examples).length > 0) { if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]); resolve(examples[Object.keys(examples)[0]]);

View File

@ -61,21 +61,21 @@ exports.deleteUser = function(username) {
* Get user by user name * Get user by user name
* *
* *
* username String The name that needs to be fetched. Use user1 for testing. * username String The name that needs to be fetched. Use user1 for testing.
* returns User * returns User
**/ **/
exports.getUserByName = function(username) { exports.getUserByName = function(username) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var examples = {}; var examples = {};
examples['application/json'] = { examples['application/json'] = {
"firstName" : "aeiou", "firstName" : "firstName",
"lastName" : "aeiou", "lastName" : "lastName",
"password" : "aeiou", "password" : "password",
"userStatus" : 6, "userStatus" : 6,
"phone" : "aeiou", "phone" : "phone",
"id" : 0, "id" : 0,
"email" : "aeiou", "email" : "email",
"username" : "aeiou" "username" : "username"
}; };
if (Object.keys(examples).length > 0) { if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]); resolve(examples[Object.keys(examples)[0]]);
@ -97,7 +97,7 @@ exports.getUserByName = function(username) {
exports.loginUser = function(username,password) { exports.loginUser = function(username,password) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var examples = {}; var examples = {};
examples['application/json'] = "aeiou"; examples['application/json'] = "";
if (Object.keys(examples).length > 0) { if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]); resolve(examples[Object.keys(examples)[0]]);
} else { } else {

View File

@ -39,5 +39,5 @@ var writeJson = exports.writeJson = function(response, arg1, arg2) {
payload = JSON.stringify(payload, null, 2); payload = JSON.stringify(payload, null, 2);
} }
response.writeHead(code, {'Content-Type': 'application/json'}); response.writeHead(code, {'Content-Type': 'application/json'});
response.end(payload, code); response.end(payload);
} }