swagger-api / swagger-api/swagger-codegen
[Java, java8,resttemplate] Generated code doesn't compile when System property 'supportingFiles' is set to 'false'
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I integrate swagger-codegen-maven-plugin's goal 'generate' into my Maven build and use following configuration:
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger.json</inputSpec>
<language>java</language>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<library>resttemplate</library>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
Calling mvn clean package produces a failing build with following output
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.685 s
[INFO] Finished at: 2019-01-07T15:13:51+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project swagger-playground: Compilation failure: Compilation failure:
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[3,25] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: package io.swagger.client
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[29,13] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.StoreApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[36,21] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.StoreApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[40,12] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.StoreApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[44,30] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.StoreApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[3,25] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: package io.swagger.client
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[31,13] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.PetApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[38,19] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.PetApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[42,12] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.PetApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[46,30] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.PetApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[3,25] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: package io.swagger.client
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[29,13] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.UserApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[36,20] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.UserApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[40,12] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.UserApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[44,30] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.UserApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/StoreApi.java:[32,18] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.StoreApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[34,18] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.PetApi
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[149,72] package ApiClient does not exist
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/PetApi.java:[186,72] package ApiClient does not exist
[ERROR] /home/sparsick/dev/workspace_github/swagger-playground/target/generated-sources/swagger/src/main/java/io/swagger/client/api/UserApi.java:[32,18] cannot find symbol
[ERROR] symbol: class ApiClient
[ERROR] location: class io.swagger.client.api.UserApi
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
When I change the property 'generateSupportingFiles' to true, the build is successful.
In case <generateSupportingFiles>false</generateSupportingFiles> following Java Classes are not generated:
- io.swagger.client.ApiClient.java
- io.swagger.client.RFC3339DateFormat.java
- io.swagger.client.auth.ApiKeyAuth.java
- io.swagger.client.auth.Authentication.java
- io.swagger.client.auth.HttpBasicAuth.java
- io.swagger.client.auth.OAuth.java
- io.swagger.client.auth.OAuthFlow.java
Swagger-codegen version
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
Swagger declaration file content or url
https://petstore.swagger.io/v2/swagger.json
Command line used for generation
git clone https://github.com/sparsick/swagger-playground
cd swagger-playground
mvn clean package
Steps to reproduce
see above
Related issues/PRs
Suggest a fix/enhancement
If you confirm that this is a bug, I could try to fix it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the swagger-playground repository and the Maven command described in the issue, using the petstore Swagger definition and generateSupportingFiles=false. Inspect the generated StoreApi.java, PetApi.java, and UserApi.java references to ApiClient and compare generation with supporting files enabled. Done means the generated client compiles without generating supporting files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100