Skip to content

Remove "nullable" in OAS 3.1? #2244

Closed
Closed

Description

@handrews

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.

Activity

  1. darrelmiller commented on May 28, 2020

    @darrelmiller
    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.

  2. rwalle61 commented on Aug 15, 2021

    @rwalle61

    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 😄

  3. handrews commented on Aug 15, 2021

    @handrews
    MemberAuthor

    @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.

  4. handrews commented on Aug 15, 2021

    @handrews
    MemberAuthor

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

  5. rwalle61 commented on Aug 22, 2021

    @rwalle61

    @handrews perfect, thanks for clarifying!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions