Skip to content
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

Remove "nullable" in OAS 3.1? #2244

Closed
handrews opened this issue May 27, 2020 · 5 comments
Closed

Remove "nullable" in OAS 3.1? #2244

handrews opened this issue May 27, 2020 · 5 comments

Comments

@handrews
Copy link
Member

Now that we have decided to discard SemVer (see PR #2243), IIRC it briefly came up on the last call that we could outright drop nullable instead of requiring that both nullable and type: "null" be supported.

Should we do this? I'd be happy to write a PR.

@darrelmiller
Copy link
Member

Now that we allow the Schema Object to allow any unknown property (to enable vocabularies) an instance of a nullable property would not fail validation rules for a 3.1 description. Be warned thought, tooling might not work as expected because the nullable keyword might not be respected.

@rwalle61
Copy link

rwalle61 commented Aug 15, 2021

Thanks for this and #2246!

To confirm, how should an openapi doc describe an object with a property 'foo' that can be string or null - just like this?

type: object
properties:
  foo:
    type: string

I couldn't find this described anywhere, and OpenAPI 3.1.0 barely mentions null.

Out of interest, is there any summary of why null has been removed since OpenAPI 3.0.3?

And fyi you may want to update this proposal about nullable to clarify that it was rejected :)

(I maintain an OpenAPI tool and a user has asked about using nullable)

Thanks again 😄

@handrews
Copy link
Member Author

@rwalle61 it's not much mentioned because it's covered by JSON Schema and OAS 3.1 tries to avoid duplicating the JSON Schema spec unless it is needed to explain how JSON Schema and OAS-specific concepts interact.

What you are looking for is:

type: object
properties:
  foo:
    type: [string, "null"]

That's the string "null", not the value null. The string "null" is the name of the type of the value null. The values in the type array can be in any order.

@handrews
Copy link
Member Author

@rwalle61 also, that nullable proposal was for 3.0, and was accepted for 3.0.3. Subsequently, nullable was removed from 3.1.0.

@rwalle61
Copy link

@handrews perfect, thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants