[BUG][Java][Spring] error: constant string too long
Created by: TruthNZ
With a large enough data model the Java-Spring server generator produces example responses with a string that is too long for the Java compiler. It's not exceeding the size of a string allowed by the JVM, but the size of a string constant the compiler handles.
default ResponseEntity<ResponseObject> restMethod(@ApiParam(value = "A Parameter",required=true) @PathVariable("parameter") String parameter) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
ApiUtil.setExampleResponse(request, "application/json", "{ [A large example json string response that breaks the Java compiler] }");
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Was generated using openapi-generator-maven-plugin 3.3.4. Settings:
<configOptions>
<sourceFolder>${generated-sources-java-path}</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
</configOptions>
<generatorName>spring</generatorName>
Potentially similar to the swagger codegen issue: https://github.com/swagger-api/swagger-codegen/issues/9055
Is an example response needed? Failing that: Could it be broken into a StringBuilder (or at worst just string concatenation)? Or maybe loaded from a resource file?