Generating a REST client for Jira Cloud

29 comments

jon martin solaas January 27, 2023
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.

java -jar openapi-generator-cli.jar generate -i https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json -g java -o ./jira-client
jon martin solaas January 27, 2023
Following up on my own post ... seems to be an issue with date/time, offset seems to be unexpected:

Caused by: java.time.format.DateTimeParseException: Text '2022-09-25T23:29:18.487+0200' could not be parsed, unparsed text found at index 26
jon martin solaas January 27, 2023

Yet a follow-up: DateTime formatting hack:

In JSON.java look for 

if (date.endsWith("+0000"))

and edit it so that it looks like

String date = in.nextString();
//if (date.endsWith("+0000")) {
if (date.contains("+")) {
date = date.substring(0, date.length()-5) + "Z";
}
return OffsetDateTime.parse(date, formatter);

(OffsetDateTimeTypeAdapter.read method)

Happy hacking ... :0)

Like Steffen Opel _Utoolity_ likes this
Ben Kelley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2023

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!

Thanks for the tip on date/time formatting.

Like Jon Martin Solaas likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events