Jira REST Client Generation Fails (Swagger / Open API Generator)

Hi. I’m trying to generate the REST client for the Jira cloud API using the open API generator but get this error. Anyone any ideas? Based off this SO question: Jira REST Client Library for Cloud - Stack Overflow

$ npx openapi-generator generate -i jiraCloudRestApi.json -g ruby
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: ruby (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator ‘ruby’ is considered stable.
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in content, returning only the first one
[main] INFO o.o.c.languages.AbstractRubyCodegen - Hint: Environment variable ‘RUBY_POST_PROCESS_FILE’ (optional) not defined. E.g. to format the source code, please try ‘export RUBY_POST_PROCESS_FILE=“/usr/local/bin/rubocop -a”’ (Linux/Mac)
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: object
[main] INFO o.o.codegen.DefaultGenerator - Model ConnectModule not generated since it’s a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model ConnectModules not generated since it’s an alias to map (without property) and generateAliasAsModel is set to false (default)
[main] INFO o.o.codegen.DefaultGenerator - Model ListWrapperCallbackApplicationRole not generated since it’s a free-form object
Exception in thread “main” java.lang.RuntimeException: Could not process model ‘FieldValueClause’.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:473)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:927)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:423)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
Caused by: java.lang.NullPointerException
at org.openapitools.codegen.DefaultCodegen.updateCodegenPropertyEnum(DefaultCodegen.java:4546)
at org.openapitools.codegen.DefaultCodegen.postProcessModelsEnum(DefaultCodegen.java:510)
at org.openapitools.codegen.languages.RubyClientCodegen.postProcessModels(RubyClientCodegen.java:491)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1203)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:468)
… 3 more

@anon20819156 – not the first time I’ve seen something like this, where the generator tool goes wonky on a valid schema (running it through openapi-generator validate -i foo.json, you’ll see that the same tool validates the schema).

The problem here is that in the FieldValueClause object, the operator property has an enum list with a bunch of logical operators (i.e. =, !=, >, <, etc.) – and they’re typed as string. However, you’ll see that null value in the list – which, by the OpenAPI spec is completely acceptable… but the openapi-generator doesn’t seem to like it.

By removing the null enum value from the list, the generator will work; however, that’s as far as my investigation went. :slight_smile:

Thanks Neil! I’ll give that a try

Hi Neil, @nmansilla,

I found the null inside Enun and I removed it but the problem remains.

13:48:36.846 [Thread-1] INFO io.swagger.codegen.v3.AbstractGenerator - writing file /Users/davi/Downloads/jira/./docs/WorkflowsApi.md
Exception in thread "Thread-1" java.lang.NullPointerException
at io.swagger.codegen.v3.utils.URLPathUtil.getServerURL(URLPathUtil.java:27)
at io.swagger.codegen.v3.utils.URLPathUtil.getScheme(URLPathUtil.java:79)
at io.swagger.codegen.v3.DefaultGenerator.buildSupportFileBundle(DefaultGenerator.java:732)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:785)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:369)
at java.lang.Thread.run(Thread.java:748)

Any other thoughts?

Best regards,

Davi

@DaviBaldin - which schema are you running against? Also, can you share your entire command from CLI?

@nmansilla - After some digging I’ve found the complete instruction: https://community.atlassian.com/t5/Jira-articles/Generating-a-REST-client-for-Jira-Cloud/ba-p/1307133 and it did worked for me.

However, I must say, the result coding was so complex to deal with than I’ve decided to write my own client using few lines of code based on Java examples in the REST API page.

Thanks,

Davi

@DaviBaldin Good news that you’re unblocked… but as for your conclusion on the generated client libs, and to instead roll your own, not surprised. I’ve heard that many times through the years.

We have updated some of the issues that made it hard to just generate a client from the spec. It also makes the type names shorter and more readable. Some details at Update to Jira Cloud's Swagger/OpenAPI docs - Atlassian Developer Blog