[BUG] [Spring] example response uses platform default charset
Created by: brabster
Bug Report Checklist
- [ /] Have you provided a full/minimal spec to reproduce the issue?
- [ /] Have you validated the input using an OpenAPI validator (example)?
- [ /] What's the version of OpenAPI Generator used?
- [ /] Have you search for related issues/PRs?
- [ /] What's the actual output vs expected output?
- [ /] [Optional] Bounty to sponsor the fix (example)
Description
SpotBugs reports an issue with the ApiUtil class - reliance on default encoding
openapi-generator version
3.3.4
OpenAPI declaration file content or url
This is in ApiUtil, so I suspect it is present in any generated API server.
Command line used for generation
Maven plugin:
<generatorName>spring</generatorName>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
<java8>true</java8>
<reactive>true</reactive>
<apiPackage>foo.bar.api</apiPackage>
<modelPackage>foo,bar.model</modelPackage>
<delegatePattern>true</delegatePattern>
</configOptions>
Steps to reproduce
Generate the api (mvn compile)
Related issues/PRs
None that I can see
Suggest a fix
I think the issue is here: https://github.com/OpenAPITools/openapi-generator/blob/68a8f2976cd0bf7af67d7568bfbba84d689cc6b2/modules/openapi-generator/src/main/resources/JavaSpring/apiUtil.mustache#L30
I see UTF-8 used elsewhere, so I think the call to String.getBytes
should specify the UTF-8 Charset.