You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The OAS 3.1 valid specification attached below throws:
java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.get$ref()" because "p" is null
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.getSchemaType(AbstractTypeScriptClientCodegen.java:774)
when attempting to generate a client for at least the following client generators:
typescript-axios
typescript-fetch
python
Interestingly enough, it passes validation via the validate command.
The seemingly problematic chunk of the spec is valid JSON Schema 2020-12 per the OAS 3.1 spec:
docker run -v .:/home openapitools/openapi-generator-cli:latest generate -i /home/openapi_3.1.0_pydantic-v2.json -o /home/dist/openapi-demo-typescript-client-openapi-generator/ -g typescript-axios
[main] WARN o.o.codegen.DefaultCodegen - Generation using 3.1.0 specs is in development and is not officially supported yet. If you would like to expedite development, please consider working on the open issues in the 3.1.0 project: https://github.com/orgs/OpenAPITools/projects/4/views/1 and reach out to our team on Slack at https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g
[main] INFO o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - Output directory (/home/dist/openapi-demo-typescript-client-openapi-generator) does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: typescript-axios (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'typescript-axios' is considered stable.
[main] INFO o.o.c.l.AbstractTypeScriptClientCodegen - Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write"' (Linux/Mac)
[main] INFO o.o.c.l.AbstractTypeScriptClientCodegen - Note: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] WARN o.o.codegen.DefaultCodegen - The value (generator's option) must be either boolean or string. Default to `false`.
[main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
[main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
[main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
[main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
[main] INFO o.o.codegen.InlineModelResolver - Inline schema created as ValidationError_loc_inner. To have complete control of the model name, set the `title` field or use the modelNameMapping option (e.g. --model-name-mappings ValidationError_loc_inner=NewModel,ModelA=NewModelA in CLI) or inlineSchemaNameMapping option (--inline-schema-name-mappings ValidationError_loc_inner=NewModel,ModelA=NewModelA in CLI).
[main] WARN o.o.codegen.DefaultCodegen - Generation using 3.1.0 specs is in development and is not officially supported yet. If you would like to expedite development, please consider working on the open issues in the 3.1.0 project: https://github.com/orgs/OpenAPITools/projects/4/views/1 and reach out to our team on Slack at https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g
[main] INFO o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO o.o.codegen.DefaultGenerator - Model Position2D not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)
[main] INFO o.o.codegen.DefaultGenerator - Model Position3D not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)
Exception in thread "main" java.lang.RuntimeException: Could not process model 'Bbox'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:521)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:446)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1296)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
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.get$ref()" because "p" is null
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.getSchemaType(AbstractTypeScriptClientCodegen.java:774)
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.lambda$getTypesFromSchemas$6(AbstractTypeScriptClientCodegen.java:1149)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.getTypesFromSchemas(AbstractTypeScriptClientCodegen.java:1152)
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.toAnyOfName(AbstractTypeScriptClientCodegen.java:1114)
at org.openapitools.codegen.DefaultCodegen.getSchemaType(DefaultCodegen.java:2229)
at org.openapitools.codegen.languages.AbstractTypeScriptClientCodegen.getSchemaType(AbstractTypeScriptClientCodegen.java:784)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3036)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1751)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:516)
... 5 more
Thanks for the quick fix! The actual OpenAPI 3.1 document that the example in this issue was derived from generated successfully 🎉 🎉. A bit difficult to diff the generated typescript-axios clients but there don't seem to be any meaningful changes in the generated interfaces that are related to BBox.
Bug Report Checklist
Description
The OAS 3.1 valid specification attached below throws:
when attempting to generate a client for at least the following client generators:
Interestingly enough, it passes validation via the
validate
command.The seemingly problematic chunk of the spec is valid JSON Schema 2020-12 per the OAS 3.1 spec:
openapi-generator version
7.8.0
OpenAPI declaration file content or url
openapi_3.1.0_pydantic-v2.json
Generation Details
validate works???
generate fails:
Steps to reproduce
where
openapi_3.1.0_pydantic-v2.json
is the json schema linked in the gist aboveRelated issues/PRs
Couldn't find any
Suggest a fix
The text was updated successfully, but these errors were encountered: