-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Trying to generate a Python client from an OpenAPI spec (which, unfortunately, I cannot share), I get this error stacktrace:
Exception: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getType()" because "schema" is null
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1145)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1036)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:561)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:878)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:432)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getType()" because "schema" is null
at org.openapitools.codegen.utils.ModelUtils.isObjectSchema(ModelUtils.java:437)
at org.openapitools.codegen.languages.PythonClientCodegen.getObjectExample(PythonClientCodegen.java:845)
at org.openapitools.codegen.languages.PythonClientCodegen.setParameterExampleValue(PythonClientCodegen.java:1212)
at org.openapitools.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:4438)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:3847)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1113)
... 6 more
When I look at the output directory, it contains only three subdirectories, docs registry_client and test and no files at all. The registry_client contains only the model subdirectory, so presumably the error happened before the code for invoking the API could be generated.
I am willing to work to get a MWE, but I need some help figuring out how to focus on the relevant part of my spec.
Note that this same specification is processed successfully (well, with some minor hiccups from anyOf processing) with the python-legacy generator).
Tested with swagger editor and it passed, with 3 warnings, which seem irrelevant:
- Use of
Acceptheader, which will be ignored. - Two schemas that are never referenced.
Notes of possible interest
In the transcript I see:
[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
I'm afraid without a line number reference, I couldn't decipher the above.
There are many lines like this:
[main] WARN o.o.c.l.PythonLegacyClientCodegen - Type null not handled properly in toExampleValue
There's this, which I'm afraid I also don't understand:
[main] WARN o.o.codegen.DefaultCodegen - More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored.
The last several lines, presumably the ones leading up to the error are these:
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
[main] WARN o.o.c.languages.PythonClientCodegen - #/components/parameters/offset is not defined
openapi-generator version
openapi-generator-cli 5.0.0
commit : d7d5e53
built : 2020-12-21T05:39:41Z
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
Generation Details
openapi-generator generate -vv --generator-name python --package-name registry_client -o /tmp/registry-client --input-spec squid-registry-v4-openapi.yaml > /tmp/openapi-generator-transcript.txt
Steps to reproduce
Related issues/PRs
None obviously jumped out at me.