Skip to content

fix(schema): include type field when nullable is used with allOf#3784

Open
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/nullable-type-field-3274
Open

fix(schema): include type field when nullable is used with allOf#3784
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/nullable-type-field-3274

Conversation

@maruthang
Copy link
Copy Markdown

PR Checklist

  • The commit message follows our guidelines
  • Tests for the changes have been added
  • Docs have been added / updated

PR Type

  • Bugfix

What is the current behavior?

When a property is UserDto | null, the schema has nullable: true and allOf: [{ $ref }] but no type field. Redocly's linter errors: "The type field must be defined when the nullable field is used."

Issue Number: #3274

What is the new behavior?

Preserves type: 'object' for nullable properties with schema combinators. The extractPropertiesFromType combinator handler now keeps type when nullable: true.

Does this PR introduce a breaking change?

  • No

When a property is nullable with a $ref (e.g. UserDto | null),
the schema had nullable: true and allOf but no type field. This
caused Redocly lint errors since OpenAPI 3.0 requires type when
nullable is present. Now preserves type: 'object' for nullable
properties with schema combinators.

Closes nestjs#3274
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant