Merge branch 'sdavis-r7-master'

This commit is contained in:
wing328 2016-06-27 16:20:58 +08:00
commit 31092585f0
7 changed files with 41 additions and 16 deletions

View File

@ -722,6 +722,15 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
} }
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger);
op.path = sanitizePath(op.path);
return op;
}
private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { private static CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) {
// This generator uses inline classes to define enums, which breaks when // This generator uses inline classes to define enums, which breaks when
// dealing with models that have subTypes. To clean this up, we will analyze // dealing with models that have subTypes. To clean this up, we will analyze
@ -811,6 +820,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
this.serializableModel = serializableModel; this.serializableModel = serializableModel;
} }
private String sanitizePath(String p) {
//prefer replace a ", instead of a fuLL URL encode for readability
return p.replaceAll("\"", "%22");
}
public void setFullJavaUtil(boolean fullJavaUtil) { public void setFullJavaUtil(boolean fullJavaUtil) {
this.fullJavaUtil = fullJavaUtil; this.fullJavaUtil = fullJavaUtil;
} }

View File

@ -684,6 +684,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
op.returnType = normalizeType(op.returnType); op.returnType = normalizeType(op.returnType);
} }
//path is an unescaped variable in the mustache template api.mustache line 82 '<&path>'
op.path = sanitizePath(op.path);
// Set vendor-extension to be used in template: // Set vendor-extension to be used in template:
// x-codegen-hasMoreRequired // x-codegen-hasMoreRequired
// x-codegen-hasMoreOptional // x-codegen-hasMoreOptional
@ -738,6 +741,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
return codegenModel; return codegenModel;
} }
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}
private String trimBrackets(String s) { private String trimBrackets(String s) {
if (s != null) { if (s != null) {
int beginIdx = s.charAt(0) == '[' ? 1 : 0; int beginIdx = s.charAt(0) == '[' ? 1 : 0;

View File

@ -86,9 +86,10 @@ use \{{invokerPackage}}\ObjectSerializer;
* Operation {{{operationId}}} * Operation {{{operationId}}}
* *
* {{{summary}}}. * {{{summary}}}.
* */
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{#allParams}} // * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * {{/allParams}}
/**
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \{{invokerPackage}}\ApiException on non-2xx response
*/ */
@ -103,9 +104,10 @@ use \{{invokerPackage}}\ObjectSerializer;
* Operation {{{operationId}}}WithHttpInfo * Operation {{{operationId}}}WithHttpInfo
* *
* {{{summary}}}. * {{{summary}}}.
* */
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{#allParams}} // * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * {{/allParams}}
/**
* @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \{{invokerPackage}}\ApiException on non-2xx response
*/ */

View File

@ -29,10 +29,11 @@ use \ArrayAccess;
/** /**
* {{classname}} Class Doc Comment * {{classname}} Class Doc Comment
* *
* @category Class * @category Class */
{{#description}} {{#description}}
* @description {{description}} // @description {{description}}
{{/description}} {{/description}}
/**
* @package {{invokerPackage}} * @package {{invokerPackage}}
* @author http://github.com/swagger-api/swagger-codegen * @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2

View File

@ -25,8 +25,9 @@ namespace {{invokerPackage}};
/** /**
* {{classname}}Test Class Doc Comment * {{classname}}Test Class Doc Comment
* *
* @category Class * @category Class */
* @description {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}} // * @description {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}}
/**
* @package {{invokerPackage}} * @package {{invokerPackage}}
* @author http://github.com/swagger-api/swagger-codegen * @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2

View File

@ -2,12 +2,11 @@
{{#appName}} {{#appName}}
* {{{appName}}} * {{{appName}}}
* *
{{/appName}} {{/appName}} */
{{#appDescription}} {{#appDescription}}
* {{{appDescription}}} //* {{{appDescription}}}
*
{{/appDescription}} {{/appDescription}}
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}} /* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
* Generated by: https://github.com/swagger-api/swagger-codegen.git * Generated by: https://github.com/swagger-api/swagger-codegen.git
* *

View File

@ -1,9 +1,9 @@
{{#appName}} {{#appName}}
{{{appName}}} #{{{appName}}}
{{/appName}} {{/appName}}
{{#appDescription}} {{#appDescription}}
{{{appDescription}}} #{{{appDescription}}}
{{/appDescription}} {{/appDescription}}
{{#version}}OpenAPI spec version: {{version}}{{/version}} {{#version}}OpenAPI spec version: {{version}}{{/version}}