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
As a user I want to generate JAVA client data types with swagger-codegen-cli using a valid OpenAPI 3 document.
When Swagger CodeGen encounters components schemas (models) with a nullable enum property of type integer, the generation fails unexpectedly with a NullPointerException (invoking java.lang.Integer.toString() on a null object, but that is intentionally because the property is nullable).
Removing the potential null value in the enum's schema elements list within the yaml source will sanitize the issue (see yaml snippet below).
The fix should respect a possible null integer enum value as specified with an appropriate OpenAPI3 schema property part (like it does with nullable string enums):
speed:
enum:
- 1200
- 2400
- 4800
- 9600
- 19200
- 38400
- 57600
- 115200
- null // <-- THIS IS THE CLASHING ELEMENT (removing it will sanitize generation run)type: integer // <-- switching this to string will also sanitize the issue, null enum valie is OK, generation runs welldescription: |- * `1200` - 1200 bps * `2400` - 2400 bps * `4800` - 4800 bps * `9600` - 9600 bps * `19200` - 19.2 kbps * `38400` - 38.4 kbps * `57600` - 57.6 kbps * `115200` - 115.2 kbpsx-spec-enum-id: ab6d9635c131a378nullable: true
The text was updated successfully, but these errors were encountered:
jenskreidler
changed the title
NullPointerException running swagger-codegen-ci for model with nullable integer enum property in schema definition
NullPointerException running swagger-codegen-cli for model with nullable integer enum property in schema definition
Apr 17, 2024
Description
As a user I want to generate JAVA client data types with swagger-codegen-cli using a valid OpenAPI 3 document.
When Swagger CodeGen encounters components schemas (models) with a nullable enum property of type integer, the generation fails unexpectedly with a NullPointerException (invoking java.lang.Integer.toString() on a null object, but that is intentionally because the property is nullable).
Removing the potential null value in the enum's schema elements list within the yaml source will sanitize the issue (see yaml snippet below).
Swagger-codegen version
Tested using swagger-code-gen 3.0.54
Swagger declaration file content or url
Issue can be verified using the Yaml OpenAPI 3 schema file of Netbox 3.7 under https://demo.netbox.dev/api/schema/
Command line used for generation
shell:
java -DmaxYamlCodePoints=40000000 -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://demo.netbox.dev/api/schema/ -l java -o ~/tmp/swagger-netbox
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
The fix should respect a possible null integer enum value as specified with an appropriate OpenAPI3 schema property part (like it does with nullable string enums):
The text was updated successfully, but these errors were encountered: