-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG][Java][Spring] error: constant string too long #2186
Comments
@TruthNZ does setting the "example" in the spec give you control on the example response? |
We have examples set in the spec. We've set them at the individual field level (large document structure with various reused elements) - and we definitely want them for our api consumers to have a good idea of formatting requirements, etc. But even if we modify it on our specific project, I believe the overall bug still needs to be dealt with. |
OK. Can you share the exact error message thrown by JVM? |
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Development/AProject/src/main/java/com/company/project/api/RestInterfaceApi.java:[53,77] constant string too long
[INFO] 1 error |
What about looping through all examples via |
Is it possible to remove this line altogether or trim it, currently some of the sample values are using the full extent of the value, IE a number is 5.6373766566333287642009963747113943099975585937 Is there any option to remove this at all? I don't really need this example response in the interface. |
@inthegarage maybe removing it from the spec as a workaround for the time being? |
@wing328 How do you mean "spec"? Is this the yaml file used to created the API or something else? |
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.
Was generated using openapi-generator-maven-plugin 3.3.4.
Settings:
Potentially similar to the swagger codegen issue: swagger-api/swagger-codegen#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?
The text was updated successfully, but these errors were encountered: