Cannot create Client API from OpenAPI Spec

Dear Jira Team,

we run Jira v7.13.8 in our company. I must access it programmatically to create Jira tasks automatically. I want to to use a small Java Client for that. So i checked if i can generate me a Java Client using OpenApi or Swagger, and i found the link to the OpenApi Spec here: https://developer.atlassian.com/cloud/jira/platform/rest/v2/

So i used the link https://developer.atlassian.com/cloud/jira/platform/swagger.v3.json to retrieve the json File needed to generate my java client. Normally i use online swagger editor to do that, as it was not let me download the File, i tried http openapi-generator . Same result.

So i switched to offline version of openapi-generator-cli-3.3.4 and swagger-codegen-cli-2.2.1. But also with no success:

java -jar openapi-generator-cli-3.3.4.jar generate -i openapi.json -g java
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO o.o.c.languages.AbstractJavaCodegen - Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try ‘export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"’ (Linux/Mac)
[main] INFO o.o.c.languages.AbstractJavaCodegen - NOTE: To enable file post-processing, ‘enablePostProcessFile’ must be set to true (–enable-post-process-file for CLI).
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
Exception in thread “main” java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Unknown Source)
at java.util.regex.Matcher.reset(Unknown Source)
at java.util.regex.Matcher.(Unknown Source)
at java.util.regex.Pattern.matcher(Unknown Source)
at org.openapitools.codegen.utils.URLPathUtils.getServerURL(URLPathUtils.java:60)
at org.openapitools.codegen.utils.URLPathUtils.getServerURL(URLPathUtils.java:50)
at org.openapitools.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:198)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:877)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:355)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)

java -jar openapi-generator-cli-3.3.4.jar generate -i swagger.v3.json -g java
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO o.o.c.languages.AbstractJavaCodegen - Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try ‘export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"’ (Linux/Mac)
[main] INFO o.o.c.languages.AbstractJavaCodegen - NOTE: To enable file post-processing, ‘enablePostProcessFile’ must be set to true (–enable-post-process-file for CLI).
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one
Exception in thread “main” java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Unknown Source)
at java.util.regex.Matcher.reset(Unknown Source)
at java.util.regex.Matcher.(Unknown Source)
at java.util.regex.Pattern.matcher(Unknown Source)
at org.openapitools.codegen.utils.URLPathUtils.getServerURL(URLPathUtils.java:60)
at org.openapitools.codegen.utils.URLPathUtils.getServerURL(URLPathUtils.java:50)
at org.openapitools.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:198)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:877)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:355)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:62)

Can you tell me what iam doing wrong? What solution did you use to test Client generation using OpenApi ?

Looking forward to a answer which helps me.
Thanks already in advance
Regards Florian

Can anyone help here?

Hi @FlorianGlaser,

your question seems to indicate that you are using Jira Server but the provided swagger-api.json is for Jira Cloud. As far as I know, there currently is no swagger definition file for Jira Server.

As a reference, please have a look here: https://developer.atlassian.com/server/jira/platform/rest-apis/

If you have the Atlassian SDK installed then you could also run a local Jira instance and install the REST API Browser App. This should give you an idea of the available endpoints.

1 Like