I'm trying to follow the steps from the swagger codegen blog post but the generated java output does not compile. I am using the verbatim codegen config json from that article, and loading the spec directly over HTTP.
swagger-codegen version:
$ swagger-codegen version
3.0.54
Codegen command:
swagger-codegen generate \
-i https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json \
-l java \
-o jira-client \
-c config.json
config.json:
{
"modelPackage": "com.atlassian.jira.rest.client.model",
"apiPackage": "com.atlassian.jira.rest.client.api",
"invokerPackage": "com.atlassian.jira.rest.client",
"library": "jersey2",
"groupId": "com.atlassian.jira.rest",
"artifactId": "client"
}
Compilation failure:
$ cd jira-client && mvn -U clean compile
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.atlassian.jira.rest:client:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:build-helper-maven-plugin is missing. @ line 87, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[WARNING] The project com.atlassian.jira.rest:client:jar:1.0.0 uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO]
[INFO] -------------------< com.atlassian.jira.rest:client >-------------------
[INFO] Building client 1.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central1: https://repo1.maven.org/maven2/org/codehaus/mojo/build-helper-maven-plugin/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/build-helper-maven-plugin/maven-metadata.xml
Downloaded from central1: https://repo1.maven.org/maven2/org/codehaus/mojo/build-helper-maven-plugin/maven-metadata.xml (915 B at 4.7 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/build-helper-maven-plugin/maven-metadata.xml (915 B at 4.7 kB/s)
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ client ---
[INFO]
[INFO] --- build-helper:3.5.0:add-source (add_sources) @ client ---
[INFO] Source directory: /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java added.
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ client ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/resources
[INFO]
[INFO] --- compiler:3.6.1:compile (default-compile) @ client ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 925 source files to /Users/mcampbell/Projects/openraven/jirav2/jira-client/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,77] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,76] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,76] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[34,1] class, interface, or enum expected
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.605 s
[INFO] Finished at: 2024-04-15T13:40:24-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project client: Compilation failure: Compilation failure:
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[31,77] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[32,76] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,30] illegal character: '#'
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,32] class, interface, or enum expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[33,76] <identifier> expected
[ERROR] /Users/mcampbell/Projects/openraven/jirav2/jira-client/src/main/java/com/atlassian/jira/rest/client/model/CustomContextVariable.java:[34,1] class, interface, or enum expected
[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
The error in the generated code, it is rendering the swagger reference id instead of the Java class name
@JsonSubTypes({
@JsonSubTypes.Type(value = #/components/schemas/IssueContextVariable.class, name = "issue"),
@JsonSubTypes.Type(value = #/components/schemas/JsonContextVariable.class, name = "jso
@JsonSubTypes.Type(value = #/components/schemas/UserContextVariable.class, name = "user"),
})
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.