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
This is by-design. The schema_for macro generates schemas which conform to JSON Schema Draft 7, which does not allow an object with the $ref property to contain any other properties (see https://tools.ietf.org/html/draft-handrews-json-schema-01#section-8.3). So in order to include any other properties (including description), the $ref is wrapped in an allOf.
The newest JSON Schema specification (draft 2019-09) does not have this restriction. Schemars supports this, albeit in a more verbose way:
let schema = SchemaSettings::draft2019_09().into_generator().into_root_schema_for::<A>();println!("{}", serde_json::to_string_pretty(&schema).unwrap());
I noticed spurious
SubschemaValidation.all_of
s with a single element being included. For example:I was able to narrow this down to a simple test case where the presence of a doc comment seems to trigger the behavior:
... which outputs:
Note that the
C
does not contain theallOf
clause (and has no doc-comment).I was able to reproduce this on 0.7.6 and 0.8.0-alpha-2.
I'm happy to fix this myself if you'd accept the PR.
The text was updated successfully, but these errors were encountered: