OpenAPI extension: x-nullable
Compatibility warning
This specification extension is supported only in OpenAPI 2.0. In OpenAPI 3.0, use nullable
. In OpenAPI 3.1, use an array of types and include null
in the list.
Use x-nullable
in your OpenAPI 2.0 documents to mark schemas with the label Nullable
in the API documentation. This indicates that the value of a particular property may be null
. Add it to the schema
OpenAPI object.
Location
Use the x-nullable
extension in an Schema object.
Options
Option | Type | Description |
---|---|---|
x-nullable | boolean | Marks schema as a nullable. |
Examples
The following example show how to mark the country
Schema as nullable
.
swagger: '2.0'
schemas:
country:
type: string
description: Country of origin
x-nullable: true
Resources
- Check out the Migration notes from OpenAPI 3.0 to 3.1 to learn more about the nullable changes in those versions.
- Control which extensions are included in your API reference documentation with the showExtensions configuration setting.
- See all openapi configuration settings.
- See a full list of supported OpenAPI extensions.