Forum Discussion

swlinn's avatar
swlinn
Occasional Contributor
5 years ago
Solved

json schema validation of null values

In reviewing the OPENAPI 3.0 specification at https://swagger.io/docs/specification/data-models/data-types/

null is not allowed as a type value, instead "the nullable attribute is used as a modifier of the base type", yet the current json schema validation specification https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 knows nothing about this nullable attribute, but does support "null" as a valid type.  Given schema definitions in swagger can be used for schema validations and the specifications contradict each other, are there any plans to allow "null" as a valid type for backward compatibility?

  • OpenAPI 3 doesn't use JSON Schema directly, but uses an "extended subset of JSON Schema". As such, some difference exist, and the behavior of 'null' and 'nullable' is an example for that. Also, OAS3 is not based on the latest JSON Schema, but an older draft version (that's known as 00 or 05).

     

    Any changes to the specification are driven by the OpenAPI Initiative and not SmartBear. You can check the work around it at https://github.com/OAI/OpenAPI-Specification/.

1 Reply

  • OpenAPI 3 doesn't use JSON Schema directly, but uses an "extended subset of JSON Schema". As such, some difference exist, and the behavior of 'null' and 'nullable' is an example for that. Also, OAS3 is not based on the latest JSON Schema, but an older draft version (that's known as 00 or 05).

     

    Any changes to the specification are driven by the OpenAPI Initiative and not SmartBear. You can check the work around it at https://github.com/OAI/OpenAPI-Specification/.