Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Support null with other types on OpenAPI 3.1 #605

Merged
merged 2 commits into from
Feb 23, 2021
Merged

Support null with other types on OpenAPI 3.1 #605

merged 2 commits into from
Feb 23, 2021

Conversation

kylef
Copy link
Member

@kylef kylef commented Feb 23, 2021

  • Removes nullable on OAS 3.1 (this is breaking change in 3.1 spec)
  • Supports type with array of 1 item alongside null (but no other case -- that will come)

@kylef kylef added the openapi3 label Feb 23, 2021
@kylef kylef requested a review from opichals February 23, 2021 10:57
const nullable = schema.getValue('nullable');
if (nullable) {
if (nullable || (type.includes('null') && element.element !== 'null')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to add nullable, only if the type isn't null.

type: null causes null element, whereas type: [string, null] means string element, that this branch makes nullable.

Copy link
Contributor

@opichals opichals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kylef kylef merged commit f781a34 into master Feb 23, 2021
@kylef kylef deleted the kylef/null branch February 23, 2021 11:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants