Use openapi-generator to avoid this. Worked for me at least. Used Java 8 to build. Didn't need any of the tweaks above to have my minimal hello-world app working. Could be needed for real-world usage though.
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2023 edited
Hi @jon martin solaas. Thanks for the comment about openapi-generator. We made a few fixes to the spec since this article was originally published, so hopefully none of the hacks are needed any more!
The generated code returns me an error in the ApprovalConfiguration.java class, specifically:
ApprovalConfiguration.java:313:35 java: incompatible types: cannot infer type arguments for java.util.ArrayList<> reason: no instance(s) of type variable(s) E exist so that java.util.ArrayList<E> conforms to jira_test.model.ApprovalConfiguration.ExcludeEnum
Is this an error due to some anomaly in the documentation structure or a problem related to Open API generator?
I was looking for the ''incriminating'' enum.
I noticed that this part is present in the JSON:
"exclude":{ "description":"A list of roles that should be excluded as possible approvers.", "enum":["assignee","reporter"], "items":{ "description":"A list of roles that should be excluded as possible approvers.", "enum":["assignee","reporter"], "nullable":true, "type":"string" }, "nullable":true, "type":"array" }
Could it be that the problem is related to the fact that it is an enum, of type string, which can accept multiple values (array)?
openapi-generator is just a jar file you can download. i tried now with swagger-codegen, after removing the enum-stuff described in the article, and it does not compile.
First error is
incompatible types: java.lang.Class<io.swagger.client.model.MandatoryFieldValue> cannot be converted to java.lang.Class<? extends io.swagger.client.model.Fields>
in JSON.java line 73 (and 74)
Do I need to dig out and old java 7 jdk to build it?
<properties> <java.version>1.7</java.version>
What is the exact swagger-codegen command line and modifications needed for the spec file? I followed the instructions in the article, maybe they're a bit outdated now?
Atlassian Team members are employees working across the company in a wide variety of roles.
November 6, 2024 edited
The instructions here are definitely outdated! A lot has changed in 4 years, including improvements to consumability of our spec. See one of my early comments on this article, linking to a new article. There should be no need to make any edits to the spec any more.
I was building using swagger-codegen-maven-plugin 3.0.63 (which calls swagger-codegen 3.0.63) using Java 17 using the "jersey1" library option, although I recommend using "resttemplate" now (as the Jersey 1 client is quite outdated).
I confirm that with swagger-codegen-maven-plugin everything was built correctly. Only thing I had to insert a dependency in pom for javax.annotations (but nothing special). At this point I assume there is something wrong with openapi-generator. I thank you for the feedback.
36 comments