Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java/Feign] Don't HTML escape Accept / Content-Type header #1022

Merged
merged 2 commits into from
May 31, 2023

Conversation

blutorange
Copy link
Contributor

When e.g. the Accept-Header contains special characters such as =, mustache escapes them, which results in code like this to be generated:

// 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=1.0; charset=utf-8,application/com.example+xml; version=1.0; charset=utf-8,application/json; charset=utf-8,application/xml; charset=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?

blutorange and others added 2 commits March 10, 2022 22:32
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?
@HugoMario HugoMario merged commit ae3b978 into swagger-api:master May 31, 2023
@HugoMario
Copy link
Contributor

thanks @blutorange !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants