question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Error processing OpenAPI json file for python client

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What’s the actual output vs expected output? (just errors out)
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Trying to process the OpenAPI spec from the Owlery system, https://github.com/phenoscape/owlery (spec posted below) with the python and python-experimental systems, I get errors processing the files.

Using the command-line locally I get:

Exception in thread "main" java.lang.RuntimeException: Could not process operation:
  Tag: class Tag {
    name: Knowledgebases
    description: null
    externalDocs: null
}
  Operation: null
  Resource: get /kbs
  Schemas: {}
  Exception: Cannot read field "isEnum" because "cp" is null

Using the docker image I get:

Exception in thread "main" java.lang.RuntimeException: Could not process operation:
  Tag: class Tag {
    name: Knowledgebases
    description: null
    externalDocs: null
}
  Operation: null
  Resource: get /kbs
  Schemas: {}
  Exception: null
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1163)
	at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1054)
	at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:549)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:891)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:441)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException
	at org.openapitools.codegen.languages.PythonClientCodegen.fromProperty(PythonClientCodegen.java:440)
	at org.openapitools.codegen.DefaultCodegen.getContent(DefaultCodegen.java:6755)
	at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:4011)
	at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1131)
	... 6 more
openapi-generator version

5.4.0

OpenAPI declaration file content or url

YAML is available here: https://gist.github.com/rpgoldman/a65d85f15a9f8b08298cb19446c1b7f0

Generation Details

I believe “steps to reproduce,” below, has all the required information, but happy to collect more if needed.

Steps to reproduce

CLI:

 openapi-generator generate --package-name owlery_client -v --generator-name python --output owlery-client -i swagger.json

Docker:

docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/swagger.json -g python-experimental -o /local/owlery-client
Related issues/PRs
Suggest a fix

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
rpgoldmancommented, Apr 13, 2022

Great, thanks. I have worked around that for now by adding schemas everywhere. I was having the error reported above when using python-experimental, but with the _JAVA_ARGS workaround now both of the code generators work for me!

4reactions
rpgoldmancommented, Apr 13, 2022

Aha! For my sub-issue 2 above, the magical answer is to prepend

_JAVA_OPTIONS="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED"

to the invocation of openapi-generator. I can use the python-experimental generator as follows:

_JAVA_OPTIONS="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED" openapi-generator generate --package-name owlery_client -vv --generator-name python-experimental --output owlery-client -i swagger.yaml 2>&1 | tee openapi-generator-experimental.out

Then it runs to completion successfully.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Zalando RESTful API and Event Guidelines
Zalando's software architecture centers around decoupled microservices that provide functionality via RESTful APIs with a JSON payload.
Read more >
JSON and APIs with Python - Towards Data Science
This pure data is often in a JSON (JavaScript Object Notation) format, which we can then parse through and extract what we need...
Read more >
How to Use Swagger Inspector
Swagger Inspector lets you make calls to an API based on the API definition. We support OpenAPI 2.0 (aka Swagger 2.0), OpenAPI 3.0,...
Read more >
Handling Errors - FastAPI
FastAPI has some default exception handlers. These handlers are in charge of returning the default JSON responses when you raise an HTTPException and...
Read more >
Minimal APIs quick reference - Microsoft Learn
When a web app is created with Visual Studio or dotnet new , a Properties/launchSettings.json file is created that specifies the ports the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found