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) {
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) {
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) {
String suffix = apiTestTemplateFiles().get(templateName);
return apiTestFileFolder() + '/' + toApiTestFilename(tag) + suffix;
return apiTestFileFolder() + File.separator + toApiTestFilename(tag) + suffix;
}
public boolean shouldOverwrite(String filename) {

View File

@ -85,7 +85,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
additionalProperties.put("serverPort", serverPort);
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,
"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) {
return outputFolder + "/" + output + "/" + apiPackage().replace('.', '/');
return outputFolder + File.separator + output + File.separator + apiPackage().replace('.', File.separatorChar);
}
/**

View File

@ -13,6 +13,7 @@ info:
license:
name: "Apache-2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "pet"

View File

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

View File

@ -11,7 +11,7 @@ info:
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
name: "Apache-2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
@ -108,11 +108,11 @@ paths:
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "csv"
responses:
200:
@ -161,6 +161,7 @@ paths:
- petstore_auth:
- "write:pets"
- "read:pets"
deprecated: true
x-swagger-router-controller: "Pet"
/pet/{petId}:
get:
@ -625,6 +626,13 @@ definitions:
default: false
title: "Pet Order"
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:
name: "Order"
Category:
@ -637,6 +645,9 @@ definitions:
type: "string"
title: "Pet category"
description: "A category for a pet"
example:
name: "name"
id: 6
xml:
name: "Category"
User:
@ -663,6 +674,15 @@ definitions:
description: "User Status"
title: "a User"
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:
name: "User"
Tag:
@ -675,6 +695,9 @@ definitions:
type: "string"
title: "Pet Tag"
description: "A tag for a pet"
example:
name: "name"
id: 1
xml:
name: "Tag"
Pet:
@ -714,6 +737,21 @@ definitions:
- "sold"
title: "a Pet"
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:
name: "Pet"
ApiResponse:
@ -728,6 +766,10 @@ definitions:
type: "string"
title: "An uploaded response"
description: "Describes the result of uploading an image resource"
example:
code: 0
type: "type"
message: "message"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"

View File

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

View File

@ -68,14 +68,14 @@ exports.getUserByName = function(username) {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = {
"firstName" : "aeiou",
"lastName" : "aeiou",
"password" : "aeiou",
"firstName" : "firstName",
"lastName" : "lastName",
"password" : "password",
"userStatus" : 6,
"phone" : "aeiou",
"phone" : "phone",
"id" : 0,
"email" : "aeiou",
"username" : "aeiou"
"email" : "email",
"username" : "username"
};
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
@ -97,7 +97,7 @@ exports.getUserByName = function(username) {
exports.loginUser = function(username,password) {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = "aeiou";
examples['application/json'] = "";
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
} else {

View File

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