How to define a property that can be string or null in OpenAPI (Swagger)?

This depends on the OpenAPI version. OpenAPI 3.1 Your example is valid in OpenAPI 3.1, which is fully compatible with JSON Schema 2020-12. type: – ‘null’ # Note the quotes around ‘null’ – string # same as type: [‘null’, string] The above is equivalent to: oneOf: – type: ‘null’ # Note the quotes around ‘null’ … Read more