-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Avoid generating uncompilable response body in Spring's API template #8691
base: master
Are you sure you want to change the base?
Conversation
e5bd6a1
to
e202250
Compare
Rebased against current master. Should fix #9055 Not sure why |
e202250
to
ceb93f9
Compare
Rebased against current master |
I can confirm this fixes #9055. With provided example, only removing duplicate white space in generated example string made the class compilable. Duplicating the billingAccounts property in CustomerAccount definition to a total of 10 instances illustrates the use of StringBuilder. |
Attaching ZIP archive with API interfaces generated by version 2.3.1 of swagger-codegen and by a snapshot with my proposed fix (with vanilla sample provided in #9055 and with extra array properties to demonstrate the use of StringBuilder) |
ceb93f9
to
3a262c3
Compare
Hi @smasset , I appologize, I missed the notification. We checked your solution out and it's working... is it possible to merge it into the upcoming version? |
…ting uncompilable example code
3a262c3
to
b32c46a
Compare
Hey @drej1. I've just rebased against latest master and didn't get any conflict. |
All checks passed. @frantuma can you include this PR in the next release ? |
Hi @diyfr, can you or somebody from the team check this PR and include it into the next release of 2.x (and also 3.x)? |
@diyfr Maybe I misunderstood something but that is a fix for OpenApi generator, not swagger codegen, no? |
Check, it's present on master branch |
Correct me if I'm wrong but there are only lambdaEscapeDoubleQuote and lambdaRemoveLineBreak in master, no lambdaTrimWhitespace*lambdaSplitString* |
@Xerocry I suggest you propose a new PR. this one is based on an obsolete branch |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.Description of the PR
If definitions start to get complicated, example response bodies can exceed Java compiler's limit for constant strings.
This PR addresses this issue by introducing and using two new lambdas to remove any unnecessary whitespace and (if still needed) to split the constant string into smaller compilable parts using a StringBuilder to merge them back again.
Fixes #9055