Avoid generating uncompilable response body in Spring's API template
PR checklist
- [x] Read the contribution guidelines.
- [x] Ran the shell script under
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif 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\. - [x] Filed the PR against the correct branch:
3.0.0branch for changes related to OpenAPI spec 3.0. Default:master. - [x] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
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
Rebased against current master. Should fix #9055
Not sure why continuous-integration/appveyor/branch check is not running automatically
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)
@frantuma, rebased this against latest master, is there anything missing in this PR ?
@drej1, can you confirm this fixes #9055 ?
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? Thanks
Hey @drej1. I've just rebased against latest master and didn't get any conflict. Let's hope all checks pass and if so feel free to merge it for the next release.
All checks passed. @frantuma can you include this PR in the next release ?
@smasset thank you very much! @frantuma any idea when this will be released? thanks :)
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)? Thanks
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)? Thanks -> @cbornet @wing328
@cbornet @wing328 any updates on this???
@cbornet @wing328 @diyfr or anybody... this is a pull request from 4 years ago...
@cbornet @wing328 @diyfr Will this ever be available? Been 5 years already..
@cbornet @wing328 @diyfr @frantuma @smasset Guys, at least give some comment, please..
@diyfr Maybe I misunderstood something but that is a fix for OpenApi generator, not swagger codegen, no? Sadly I can't switch cause of complex structure openapi plugin is running out of space and it would be great to have fix in swagger-codegen too :)
@diyfr Maybe I misunderstood something but that is a fix for OpenApi generator, not swagger codegen, no? Sadly I can't switch cause of complex structure openapi plugin is running out of space and it would be great to have fix in swagger-codegen too :)
Check, it's present on master branch
@wing328 @frantuma you can close this pull request
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
@diyfr I've just created a new PR #12136 cherry-picking all commits from this one without any conflict. Can you approve the workflows there ? I can also rebase this PR's branch against latest master if you prefer. Let me know what is more convenient for you