We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serde allows to add #[serde(untagged)] to individual enum variants.
#[serde(untagged)]
See here for an example of the working serde code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=75fc42b60b77cca8eeeb8fab53a3f78c
If I add schemars to this, the generated schema is wrong:
#![allow(dead_code)] use serde_derive::{Serialize, Deserialize}; use schemars::{schema_for, JsonSchema}; #[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(tag = "type")] enum StructuralSubElement { Title, Subtitle, Decoration, Docinfo, #[serde(untagged)] SubStructure(SubStructure), } #[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(tag = "type")] enum SubStructure { Topic, Sidebar, Transition, Section, BodyElement } fn main() { let schema = schema_for!(StructuralSubElement); println!("{}", serde_json::to_string_pretty(&schema).unwrap()); }
The resulting schema has this wrong "const": "SubStructure" constraint:
"const": "SubStructure"
{ "StructuralSubElement": { "oneOf": [ ..., { "type": "object", "properties": { "type": { "type": "string", "const": "SubStructure" } }, "$ref": "#/$defs/SubStructure", "required": ["type"] } ] } }
Maybe related: #311
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
Serde allows to add
#[serde(untagged)]
to individual enum variants.See here for an example of the working serde code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=75fc42b60b77cca8eeeb8fab53a3f78c
If I add schemars to this, the generated schema is wrong:
The resulting schema has this wrong
"const": "SubStructure"
constraint:Maybe related: #311
The text was updated successfully, but these errors were encountered: