Skip to content

Add nullable property to indicate a type can be null #1067

Closed
@santialbo

Description

@santialbo

Current situation

Nullable types are very common in JSON world.
In order to make a type nullable either you have to add "null" to the types array or use oneOf

{ "type": ["string", "null"] }
{ "oneOf": [ { "type": "string" }, { "type": "null" } ] }

Rationale

I believe this approach of making a type nullable is not very intuitive 1.

At least one other specification (OpenAPI) supports an extension of the JSON schema spec that includes the nullable property2.

I suggest adding this nullable: boolean property to the JSON schema spec as a more intuitive and less verbose way of making types nullable.

1 https://stackoverflow.com/search?q=json+schema+nullable
2 https://swagger.io/specification/#fixed-fields-20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions