Skip to content

Commit f0e2f97

Browse files
authored
[Java/Feigh] Don't HTML escape Accept / Content-Type header
When e.g. the Accept-Header contains special characters such as `=`, mustache escapes them, which results in code like this to be generated: ```java // MyApi.java public interface MyApi extends ApiClient.Api { @RequestLine("GET /rest/protected/items?size={size}&page={page}") @headers({ "Content-Type: */*", "Accept: application/com.example+json; version&#x3D;1.0; charset&#x3D;utf-8,application/com.example+xml; version&#x3D;1.0; charset&#x3D;utf-8,application/json; charset&#x3D;utf-8,application/xml; charset&#x3D;utf-8", }) LicenseListResource getLicenses(@QueryMap(encoded=true) Map<String, Object> queryParams); } ``` Note the `Accept: application/com.example+json; version&#x3D;1.0; charset&#x3D;utf-8` with the escaped `=`, which does not work. This disables HTML escaping for the header values. On a side note though, I had been wondering whether HTML escaping makes sense when generating Java files? It does in JavaDocs I suppose, but shouldn't it be disabled everywhere else?
1 parent 63252dd commit f0e2f97

File tree

1 file changed

+4
-4
lines changed
  • src/main/resources/handlebars/Java/libraries/feign

1 file changed

+4
-4
lines changed

src/main/resources/handlebars/Java/libraries/feign/api.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public interface {{classname}} extends ApiClient.Api {
4040
@RequestLine("{{httpMethod}} {{{path}}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{baseName}}={{braces "left"}}{{paramName}}{{braces "right"}}{{#has this 'more'}}&{{/has}}{{/queryParams}}")
4141
@Headers({
4242
{{#vendorExtensions.x-contentType}}
43-
"Content-Type: {{vendorExtensions.x-contentType}}",
43+
"Content-Type: {{{vendorExtensions.x-contentType}}}",
4444
{{/vendorExtensions.x-contentType}}
4545
{{#vendorExtensions.x-accepts}}
46-
"Accept: {{vendorExtensions.x-accepts}}",
46+
"Accept: {{{vendorExtensions.x-accepts}}}",
4747
{{/vendorExtensions.x-accepts}}
4848
{{^vendorExtensions.x-accepts}}
4949
"Accept: */*",
@@ -85,13 +85,13 @@ public interface {{classname}} extends ApiClient.Api {
8585
@RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{braces "left"}}{{paramName}}{{braces "right"}}{{#has this 'more'}}&{{/has}}{{/queryParams}}")
8686
@Headers({
8787
{{#vendorExtensions.x-contentType}}
88-
"Content-Type: {{vendorExtensions.x-contentType}}",
88+
"Content-Type: {{{vendorExtensions.x-contentType}}}",
8989
{{/vendorExtensions.x-contentType}}
9090
{{^vendorExtensions.x-contentType}}
9191
"Content-Type: */*",
9292
{{/vendorExtensions.x-contentType}}
9393
{{#vendorExtensions.x-accepts}}
94-
"Accept: {{vendorExtensions.x-accepts}}",
94+
"Accept: {{{vendorExtensions.x-accepts}}}",
9595
{{/vendorExtensions.x-accepts}}
9696
{{#headerParams}}
9797
"{{baseName}}: {{braces "left"}}{{paramName}}{{braces "right"}}"{{#has this 'more'}},{{/has}}

0 commit comments

Comments
 (0)