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
Have you tested with the latest master to confirm the issue still exists?
I used openapi-generator-cli-7.13.0-20250307.080352-24.jar from sonatype
Have you searched for related issues/PRs?
I've read many issues about nullable and type: 'null', I don't think there is an open issue for this.
What's the actual output vs expected output?
See below
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When using allOf and 2 references, the generated classes do not use JsonNullable. However, when the properties are defined inline (without using $ref) JsonNullable is generated. A type: [string, "null"] should generate JsonNullable (or Optional) regardless of whether the field is included with allOf or not.
openapi-generator version
I tested this with 7.11.0 with the maven plugin, as well as the 7.13.0 snapshot build above.
I'm upgrading from version 6.6.0, and spec version 3.0 (replacing type: [string, "null"] with type: string and nullable: true), and I see JsonNullable in both cases.
OpenAPI declaration file content or url
Here is my spec, nullableAllOfSpec.yaml
openapi: 3.1.0info:
title: Test APIversion: "1.0"paths:
/itemsInline:
get:
operationId: getInlinesummary: Get a list of itemsdescription: Retrieves a list of itemsresponses:
default: # creates GetInlineDefaultResponse, with 1 JsonNullable field and one plain String fielddescription: Items retrievedcontent:
application/json:
schema:
type: objectproperties:
nonNullablePropertyInline:
type: stringnullablePropertyInline:
type: [string, "null"]/itemsAllOf:
get:
operationId: getAllOfsummary: Get a list of itemsdescription: Retrieves a list of itemsresponses:
default: # creates GetAllOfDefaultResponse, with 2 plain String field, even though NullablePropertyList has a JsonNullable propertydescription: Items retrievedcontent:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/NullablePropertyList'
- $ref: '#/components/schemas/NonNullablePropertyList'components:
schemas:
NullablePropertyList: # Creates NullablePropertyList, with a JsonNullablePropertytype: objectproperties:
nullableProperty:
type: [ string, "null" ]NonNullablePropertyList:
type: objectproperties:
nonNullableProperty:
type: string
Generation Details
java -jar openapi-generator-cli-7.13.0-20250307.080352-24.jar generate -i NullableAllOf/src/main/resources/nullableAllOfSpec.yaml -g spring --library 'spring-boot'
Steps to reproduce
Run the generate command in generation details.
Specifically, I expected GetAllOfDefaultResponse.java to have.
Also, I'm not sure about the @Nullable annotation from org.springframework.lang.Nullable. I didn't have this in the previous generator and OAS version, but it seems like JsonNullable is still supported and I'd like to continue using that.
Related issues/PRs
Didn't find any
Suggest a fix
I added some comments in nullableDataType.mustache and nullableDataTypeBeanValidation.mustache, and it appears the isNullable flag is not getting set to true when being passed to nullableDataTypeBeanValidation.mustache, but only in the allOf context when generating GetAllOfDefaultResponse. The same comments indicate isNullable is set to true when generating the NullablePropertyList.
I could look into this further and possibly create a PR, but at this point I was looking for confirmation on if this is a bug or something else happened like I missed a configuration.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
See below
https://apitools.dev/swagger-parser/online no longer works, so I used https://oas-validation.com/
I used openapi-generator-cli-7.13.0-20250307.080352-24.jar from sonatype
I've read many issues about nullable and type: 'null', I don't think there is an open issue for this.
See below
Description
When using allOf and 2 references, the generated classes do not use JsonNullable. However, when the properties are defined inline (without using $ref) JsonNullable is generated. A
type: [string, "null"]
should generate JsonNullable (or Optional) regardless of whether the field is included with allOf or not.openapi-generator version
I tested this with 7.11.0 with the maven plugin, as well as the 7.13.0 snapshot build above.
I'm upgrading from version 6.6.0, and spec version 3.0 (replacing type: [string, "null"] with type: string and nullable: true), and I see JsonNullable in both cases.
OpenAPI declaration file content or url
Here is my spec,
nullableAllOfSpec.yaml
Generation Details
java -jar openapi-generator-cli-7.13.0-20250307.080352-24.jar generate -i NullableAllOf/src/main/resources/nullableAllOfSpec.yaml -g spring --library 'spring-boot'
Steps to reproduce
Run the generate command in generation details.
Specifically, I expected GetAllOfDefaultResponse.java to have.
instead of
Also, I'm not sure about the
@Nullable
annotation from org.springframework.lang.Nullable. I didn't have this in the previous generator and OAS version, but it seems like JsonNullable is still supported and I'd like to continue using that.Related issues/PRs
Didn't find any
Suggest a fix
I added some comments in nullableDataType.mustache and nullableDataTypeBeanValidation.mustache, and it appears the isNullable flag is not getting set to true when being passed to nullableDataTypeBeanValidation.mustache, but only in the allOf context when generating GetAllOfDefaultResponse. The same comments indicate isNullable is set to true when generating the NullablePropertyList.
I could look into this further and possibly create a PR, but at this point I was looking for confirmation on if this is a bug or something else happened like I missed a configuration.
The text was updated successfully, but these errors were encountered: