Skip to content
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 #2903

Merged
merged 5 commits into from
Nov 12, 2019

Conversation

smasset
Copy link
Contributor

@smasset smasset commented May 15, 2019

PR checklist

  • Read the contribution guidelines.
  • 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.sh, ./bin/openapi3/{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\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • 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 #2186

@smasset
Copy link
Contributor Author

smasset commented May 15, 2019

CCing Java technical committee for review : @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog

@smasset smasset changed the title Long example string Avoid generating uncompilable response body in Spring's API template May 15, 2019
@smasset smasset force-pushed the long-example-string branch from 29cadc5 to bba06ef Compare May 16, 2019 22:08
@smasset
Copy link
Contributor Author

smasset commented May 16, 2019

Just pushed updated samples

@smasset smasset force-pushed the long-example-string branch from bba06ef to f82de07 Compare May 17, 2019 04:59
@smasset
Copy link
Contributor Author

smasset commented May 17, 2019

@wing328, as discussed, here's the PR porting swagger-api/swagger-codegen#8691 to openapi-generator

@wing328 wing328 added this to the 4.0.3 milestone Jun 25, 2019
@wing328 wing328 modified the milestones: 4.0.3, 4.1.0 Jul 9, 2019
@wing328
Copy link
Member

wing328 commented Aug 8, 2019

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04)

@wing328 wing328 modified the milestones: 4.1.0, 4.1.1 Aug 9, 2019
@wing328 wing328 modified the milestones: 4.1.1, 4.1.2 Aug 26, 2019
@smasset
Copy link
Contributor Author

smasset commented Aug 30, 2019

Is there anything missing in the PR ?
cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) cc @wing328

@wing328 wing328 modified the milestones: 4.1.2, 4.1.3 Sep 11, 2019
@wing328 wing328 modified the milestones: 4.1.3, 4.2.0 Oct 4, 2019
@wing328 wing328 removed this from the 4.2.0 milestone Oct 30, 2019
@wing328
Copy link
Member

wing328 commented Nov 12, 2019

@smasset thanks for the PR and my apologies for taking so long to review this change.

Let's go with this enhancement in the upcoming release.

@wing328 wing328 merged commit 99204ec into OpenAPITools:master Nov 12, 2019
jimschubert added a commit that referenced this pull request Nov 13, 2019
* master:
  [csharp-netcore] Propagate raw content to the ApiException error content. (#4381)
  Remove path relative to my home dir. (#4470)
  Avoid generating uncompilable response body in Spring's API template (#2903)
  cpp-qt5-client: remove host since it is not well handled (#4429)
  [Java] Refactor webClient generator to use URI templates to capture correct metrics (#4314)
  [Java]: Client resttemplate and webclient: array parameters of type integer in path badly generated (#4379)
  Dart generate keywords (#4449)
  [core] Fix system properties being immutable (#4447)
  [Kotlin][Client] minor improvements (#4419)
  [typescript-rxjs]: Add support for nullable (#4438)
  [asciidoc] fix names of parameters (#4440)
@smasset
Copy link
Contributor Author

smasset commented Nov 19, 2019

Great news.
@wing328, although the code definitely is tagged as part of 4.2.1 release, it doesn't appear in the release notes. I think the PR is missing the 4.2.1 milestone.

@wing328 wing328 added this to the 4.2.2 milestone Dec 2, 2019
@wing328
Copy link
Member

wing328 commented Dec 2, 2019

@smasset thanks for the PR, which has been included in the v4.2.2 release: https://twitter.com/oas_generator/status/1201432648544972800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][Java][Spring] error: constant string too long
2 participants