-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] NullPointerException when I attempt to generate a Python API client #20348
Comments
https://gist.github.com/joseph-grosso/436781d1e73d66f77bb6c0a2933885af returns 404 can you please reshare the spec? |
I am getting similar behaviour when trying to generate a python client from this Spec file Tail of the console output as it is very long:
|
thanks for sharing a spec. I can reproduce the issue and will try to come up with a fix. |
can you please try using the e.g.
|
I tried this option with my generation again and still have that same error. Command (with version 7.10): openapi-generator generate -i ../openapi/swagger.json -g python -o ./python-api --inline-schema-options REFACTOR_ALLOF_INLINE_SCHEMAS=true Last few lines of output: [main] INFO o.o.codegen.DefaultGenerator - Model MeasurementQuantityList 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 NetworkFlowList not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: null
[main] WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: object. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)
[main] INFO o.o.codegen.DefaultGenerator - Model PermissionDecision 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 PermissionsInput 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 PermissionsOutput 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 UserPermissions 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 CalculatorInputs 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 IListCommentResponse 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 CommentEntityIds 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 ICommentCountResponse 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 BulkAddEstimationMethodToEntitiesRequest 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 CustomAttributeConfigurationInput 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 RecordFilterFields_allOf_flow_associated_facility_custom_attributes not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model ICreateWorkflowTemplateInput_allOf_asset_filter not generated since it's a free-form object
Exception in thread "main" java.lang.NullPointerException
at org.openapitools.codegen.languages.AbstractPythonCodegen.getModelNameFromDataType(AbstractPythonCodegen.java:1176)
at org.openapitools.codegen.languages.AbstractPythonCodegen.getModelNameFromDataType(AbstractPythonCodegen.java:1179)
at org.openapitools.codegen.languages.AbstractPythonCodegen.createImportMapOfSet(AbstractPythonCodegen.java:1159)
at org.openapitools.codegen.languages.AbstractPythonCodegen.postProcessAllModels(AbstractPythonCodegen.java:858)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:536)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:453)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1303)
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) |
@joseph-grosso can you please share the spec so that we can use it to troubleshoot the issue? |
My company's spec isn't available publicly, so I don't want to share the full document here. I can anonymize the spec but that will take time to do as it is very long. I will shorten it and try to isolate the issue but that will take some time. Will post that when I have the bandwidth to take on that work. |
@joseph-grosso would it be possible to send the spec file via email (in my github profile) to me directly? I won't share with others. |
Bug Report Checklist
I don't want to share the full spec as this is used internally and is quite long/would take a while to anonymize.
I validated the swagger file with both the swagger online editor and the
openapi-generator
validator:openapi-generator validate -i redocly.swagger.yaml
Description
I'm getting a NullPointerException when I attempt to generate a Python API client:
I can generate a client with other paid tools (speakeasy), but I'd prefer to use the free and open source tooling available here.
openapi-generator version
7.11.0-SNAPSHOT
OpenAPI declaration file content or url
https://gist.github.com/joseph-grosso/436781d1e73d66f77bb6c0a2933885af
Generation Details
Steps:
openapi-generator generate -i redocly.swagger.yaml -g python -o ../python-api
Suggest a fix
The error returned:
Hopefully if the null was handled differently in this step then this could pass.
The full error output
I believe that the issue is related to one of the warnings below:
null
containing multiple types (not model) is not supported at the moment."generateAliasAsModel
is set to false (default)The text was updated successfully, but these errors were encountered: