Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2186
Closed
Open
Issue created Feb 18, 2019 by Administrator@rootContributor

[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?

Assignee
Assign to
Time tracking