You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the referenced JSON Schema Validation for OAS3.1, the enum property can be of any valid type (presumably matching the multi-valued type fields, including null.
This was observed in the wild when attempting to parse GitHub OpenAPI 3.1 specification, which includes schemas with multi-type, where one type is null.
This can be demonstrated with the following:
use oas3::spec::ObjectSchema;fnmain(){let json = serde_json::json!({"type":["string","null"],"enum":["one", null]});let object:ObjectSchema = serde_json::from_value(json).unwrap();}
produces
called `Result::unwrap()` on an `Err` value: Error("invalid type: null, expected a string", line: 0, column: 0)`
The same is true when done through the ObjectOrReference<ObjectSchema>, but with a more diffuse error message:
use oas3::spec::{ObjectOrReference,ObjectSchema};fnmain(){let json = serde_json::json!({"type":["string","null"],"enum":["one", null]});let reference:ObjectOrReference<ObjectSchema> = serde_json::from_value(json).unwrap();}
produces
called `Result::unwrap()` on an `Err` value: Error("data did not match any variant of untagged enum ObjectOrReference", line: 0, column: 0)
The text was updated successfully, but these errors were encountered:
According to the referenced JSON Schema Validation for OAS3.1, the enum property can be of any valid type (presumably matching the multi-valued
type
fields, includingnull
.This was observed in the wild when attempting to parse GitHub OpenAPI 3.1 specification, which includes schemas with multi-type, where one type is
null
.This can be demonstrated with the following:
produces
The same is true when done through the
ObjectOrReference<ObjectSchema>
, but with a more diffuse error message:produces
The text was updated successfully, but these errors were encountered: