cancel
Showing results for 
Search instead for 
Did you mean: 

json schema validation of null values

SOLVED
Occasional Contributor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: json schema validation of null values

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

1 REPLY 1
Moderator

Re: json schema validation of null values

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

New Here?
Join us and watch the welcome video: