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

[Java] supporting files like ApiClient cannot be generated because of bug in 2.4.6 #9540

Open
florimon opened this issue Jul 3, 2019 · 5 comments

Comments

@florimon
Copy link

florimon commented Jul 3, 2019

Description

Due to a breaking change in 2.4.6 (compared to 2.4.5), generating supporting files like e.g. ApiClient.java that are necessary for producing a working client has become impossible.

Swagger-codegen version

version 2.4.6

Swagger declaration file content or url

any yaml (e.g. petstore).

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http:https://petstore.swagger.io/v2/swagger.json -l java --library resttemplate -o ../petstore-server

Steps to reproduce
  1. Use any yaml or json service description (e.g. petstore)
  2. try to generate a client for language "java", and library "resttemplate"
  3. observe that NO supporting files have been generated in the output directory (so no ApiClient in the (specified or implicit) invokerPackage)
Related issues/PRs

none

Suggest a fix/enhancement

The problem is with the 2.4.6 version of io.swagger.codegen.DefaultGenerator#configureGeneratorProperties(), specifically line 138 (which was line 130 in 2.4.5).
Whereas the 2.4.5 version was setting the isGenerateSupportingFiles boolean flag to TRUE whenever a non-null system property "supportingFiles" existed, the 2.4.6 version only sets this flag to TRUE when that system property exists, AND is equal to (ignoring case) "true".
The problem with this, is that this system property serves a dual purpose - DefaultGenerator.generateSupportingFiles() interprets it as a comma separated 'whitelist' of supporting files to generate; lines 588 - 594 (of the 2.4.6 version) skip any file to be generated, if its name is not contained within this comma separated list.
So, setting -DsupportingFiles=true does not help in 2.4.6, since the whitelist will be "true" and of course no supporting files match that.

Fix/enhancement: either

  1. revert the change that was made in 2.4.6, or
  2. retire the code in lines 588 - 594, or
  3. use a different property name if the 'whitelist' functionality is to be maintained.
@chrisinmtown
Copy link

Thanks @florimon for writing this up better than I could, I hope the team will add a regression test case for this, because this bug completely blew us out of the water also.

@carlosrogue
Copy link

I had a similar issue while using swagger-codegen-gradle, so this configuration:

components = [apis: true, models: true, supportingFiles: true]

Works on 2.4.5 but not 2.4.6.

@frantuma
Copy link
Member

frantuma commented Jul 8, 2019

@florimon @chrisinmtown @carlosrogue Thanks a lot for the detailed info and for spotting the bug! it's indeed a regression, fixed in #9550, available in latest 2.4.7-SNAPSHOT and in upcoming 2.4.7 release

frantuma added a commit that referenced this issue Jul 8, 2019
ref #9540 - fix regression in generate options
frantuma added a commit that referenced this issue Jul 8, 2019
frantuma added a commit that referenced this issue Jul 9, 2019
@chrisinmtown
Copy link

Version 2.4.7 works on my code, thanks.

@rhysstubbs
Copy link

Sorry to comment with a slightly unrelated question, however, could someone point me in the direction of the documentation for supporting files? I cannot find a reference to it anywhere! I have various classes that are not generated from the specification but I would like them generated alongside the rest of the library. An example is what @florimon mentioned, I have a entry point class ApiClient (.php in my case) and currently I've got a little bash script that does some find and replace with regex to put in some extra things related to the Api and Model classes generated

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

No branches or pull requests

5 participants