forked from loafle/openapi-generator-original
fix accepts, contentType with unescaped values (#19915)
This commit is contained in:
parent
c8f2d2be1f
commit
ec98693da5
@ -155,9 +155,9 @@ public class {{classname}} {
|
|||||||
this.reqSpec = reqSpec;
|
this.reqSpec = reqSpec;
|
||||||
{{#vendorExtensions}}
|
{{#vendorExtensions}}
|
||||||
{{#x-content-type}}
|
{{#x-content-type}}
|
||||||
reqSpec.setContentType("{{x-content-type}}");
|
reqSpec.setContentType("{{{x-content-type}}}");
|
||||||
{{/x-content-type}}
|
{{/x-content-type}}
|
||||||
reqSpec.setAccept("{{#x-accepts}}{{.}}{{^-last}},{{/-last}}{{/x-accepts}}");
|
reqSpec.setAccept("{{#x-accepts}}{{{.}}}{{^-last}},{{/-last}}{{/x-accepts}}");
|
||||||
{{/vendorExtensions}}
|
{{/vendorExtensions}}
|
||||||
this.respSpec = new ResponseSpecBuilder();
|
this.respSpec = new ResponseSpecBuilder();
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ public interface {{classname}} {
|
|||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
method = RequestMethod.{{httpMethod}},
|
method = RequestMethod.{{httpMethod}},
|
||||||
value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}},
|
value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}},
|
||||||
produces = { {{#vendorExtensions.x-accepts}}"{{.}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{/hasProduces}}{{#hasConsumes}},
|
produces = { {{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}},
|
produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}}{{#hasVersionHeaders}},
|
consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}}{{#hasVersionHeaders}},
|
||||||
|
@ -54,7 +54,7 @@ public interface {{classname}} {
|
|||||||
@HttpExchange(
|
@HttpExchange(
|
||||||
method = "{{{httpMethod}}}",
|
method = "{{{httpMethod}}}",
|
||||||
value = "{{{path}}}",
|
value = "{{{path}}}",
|
||||||
accept = { {{#vendorExtensions.x-accepts}}"{{.}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{#vendorExtensions.x-content-type}},
|
accept = { {{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} }{{#vendorExtensions.x-content-type}},
|
||||||
contentType = "{{{vendorExtensions.x-content-type}}}"{{/vendorExtensions.x-content-type}}
|
contentType = "{{{vendorExtensions.x-content-type}}}"{{/vendorExtensions.x-content-type}}
|
||||||
)
|
)
|
||||||
{{>responseType}} {{operationId}}(
|
{{>responseType}} {{operationId}}(
|
||||||
|
@ -139,10 +139,10 @@ class {{classname}}Spec extends Specification {
|
|||||||
MutableHttpRequest request = HttpRequest.{{httpMethod}}{{#vendorExtensions.methodAllowsBody}}{{#bodyParam}}(uri, body){{/bodyParam}}{{#isMultipart}}{{^formParams}}(uri, body){{/formParams}}{{/isMultipart}}{{#formParams.0}}(uri, form){{/formParams.0}}{{^bodyParam}}{{^isMultipart}}{{^formParams}}(uri, null){{/formParams}}{{/isMultipart}}{{/bodyParam}}{{/vendorExtensions.methodAllowsBody}}{{^vendorExtensions.methodAllowsBody}}(uri){{/vendorExtensions.methodAllowsBody}}
|
MutableHttpRequest request = HttpRequest.{{httpMethod}}{{#vendorExtensions.methodAllowsBody}}{{#bodyParam}}(uri, body){{/bodyParam}}{{#isMultipart}}{{^formParams}}(uri, body){{/formParams}}{{/isMultipart}}{{#formParams.0}}(uri, form){{/formParams.0}}{{^bodyParam}}{{^isMultipart}}{{^formParams}}(uri, null){{/formParams}}{{/isMultipart}}{{/bodyParam}}{{/vendorExtensions.methodAllowsBody}}{{^vendorExtensions.methodAllowsBody}}(uri){{/vendorExtensions.methodAllowsBody}}
|
||||||
{{!Fill in all the request parameters}}
|
{{!Fill in all the request parameters}}
|
||||||
{{#vendorExtensions.x-content-type}}
|
{{#vendorExtensions.x-content-type}}
|
||||||
.contentType('{{vendorExtensions.x-content-type}}')
|
.contentType('{{{vendorExtensions.x-content-type}}}')
|
||||||
{{/vendorExtensions.x-content-type}}
|
{{/vendorExtensions.x-content-type}}
|
||||||
{{#vendorExtensions.x-accepts}}
|
{{#vendorExtensions.x-accepts}}
|
||||||
.accept('{{vendorExtensions.x-accepts}}')
|
.accept('{{{vendorExtensions.x-accepts}}}')
|
||||||
{{/vendorExtensions.x-accepts}}
|
{{/vendorExtensions.x-accepts}}
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
.header('{{{baseName}}}', {{{vendorExtensions.groovyExample}}}{{^isString}}.toString(){{/isString}})
|
.header('{{{baseName}}}', {{{vendorExtensions.groovyExample}}}{{^isString}}.toString(){{/isString}})
|
||||||
|
@ -146,8 +146,8 @@ public class {{classname}}Test {
|
|||||||
{{closebrace}}{{closebrace}}{{/pathParams.0}});
|
{{closebrace}}{{closebrace}}{{/pathParams.0}});
|
||||||
{{!Create the request with body and uri}}
|
{{!Create the request with body and uri}}
|
||||||
MutableHttpRequest<?> request = HttpRequest.{{httpMethod}}{{#vendorExtensions.methodAllowsBody}}{{#bodyParam}}(uri, body){{/bodyParam}}{{#isMultipart}}{{^formParams}}(uri, body){{/formParams}}{{/isMultipart}}{{#formParams.0}}(uri, form){{/formParams.0}}{{^bodyParam}}{{^isMultipart}}{{^formParams}}(uri, null){{/formParams}}{{/isMultipart}}{{/bodyParam}}{{/vendorExtensions.methodAllowsBody}}{{^vendorExtensions.methodAllowsBody}}(uri){{/vendorExtensions.methodAllowsBody}}{{!Fill in all the request parameters}}{{#vendorExtensions.x-contentType}}
|
MutableHttpRequest<?> request = HttpRequest.{{httpMethod}}{{#vendorExtensions.methodAllowsBody}}{{#bodyParam}}(uri, body){{/bodyParam}}{{#isMultipart}}{{^formParams}}(uri, body){{/formParams}}{{/isMultipart}}{{#formParams.0}}(uri, form){{/formParams.0}}{{^bodyParam}}{{^isMultipart}}{{^formParams}}(uri, null){{/formParams}}{{/isMultipart}}{{/bodyParam}}{{/vendorExtensions.methodAllowsBody}}{{^vendorExtensions.methodAllowsBody}}(uri){{/vendorExtensions.methodAllowsBody}}{{!Fill in all the request parameters}}{{#vendorExtensions.x-contentType}}
|
||||||
.contentType("{{vendorExtensions.x-contentType}}"){{/vendorExtensions.x-contentType}}{{#vendorExtensions.x-accepts}}
|
.contentType("{{{vendorExtensions.x-contentType}}}"){{/vendorExtensions.x-contentType}}{{#vendorExtensions.x-accepts}}
|
||||||
.accept("{{vendorExtensions.x-accepts}}"){{/vendorExtensions.x-accepts}}{{#headerParams}}
|
.accept("{{{vendorExtensions.x-accepts}}}"){{/vendorExtensions.x-accepts}}{{#headerParams}}
|
||||||
.header("{{{baseName}}}", {{^isString}}String.valueOf({{/isString}}{{{example}}}{{^isString}}){{/isString}}){{/headerParams}}{{#cookieParams}}
|
.header("{{{baseName}}}", {{^isString}}String.valueOf({{/isString}}{{{example}}}{{^isString}}){{/isString}}){{/headerParams}}{{#cookieParams}}
|
||||||
.cookie(Cookie.of("{{{baseName}}}", {{{example}}})){{/cookieParams}};
|
.cookie(Cookie.of("{{{baseName}}}", {{{example}}})){{/cookieParams}};
|
||||||
{{!Fill in the query parameters}}
|
{{!Fill in the query parameters}}
|
||||||
|
@ -58,7 +58,7 @@ public interface {{classname}} {
|
|||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
method = RequestMethod.{{httpMethod}},
|
method = RequestMethod.{{httpMethod}},
|
||||||
value = "{{{path}}}"{{#singleContentTypes}},
|
value = "{{{path}}}"{{#singleContentTypes}},
|
||||||
produces = { {{#vendorExtensions.x-accepts}}"{{.}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} },
|
produces = { {{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}} },
|
||||||
consumes = "{{{vendorExtensions.x-content-type}}}"{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}},
|
produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}}
|
consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
|
@ -84,7 +84,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
|
|||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
method = [RequestMethod.{{httpMethod}}],
|
method = [RequestMethod.{{httpMethod}}],
|
||||||
value = ["{{#lambdaEscapeInNormalString}}{{path}}{{/lambdaEscapeInNormalString}}"]{{#singleContentTypes}}{{#hasProduces}},
|
value = ["{{#lambdaEscapeInNormalString}}{{path}}{{/lambdaEscapeInNormalString}}"]{{#singleContentTypes}}{{#hasProduces}},
|
||||||
produces = [{{#vendorExtensions.x-accepts}}"{{.}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
|
produces = [{{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
|
@ -97,7 +97,7 @@ interface {{classname}} {
|
|||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
method = [RequestMethod.{{httpMethod}}],
|
method = [RequestMethod.{{httpMethod}}],
|
||||||
value = ["{{#lambdaEscapeInNormalString}}{{path}}{{/lambdaEscapeInNormalString}}"]{{#singleContentTypes}}{{#hasProduces}},
|
value = ["{{#lambdaEscapeInNormalString}}{{path}}{{/lambdaEscapeInNormalString}}"]{{#singleContentTypes}}{{#hasProduces}},
|
||||||
produces = [{{#vendorExtensions.x-accepts}}"{{.}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
|
produces = [{{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user