-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
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
Subschema inlining on Newtype enums even with latest changes. #356
Comments
That's odd - it looks like the changes around internally-tagged newtype variants weren't actually included in the published crate. It's possible I forgot to update my local master branch before publishing... I've now published v1.0.0-alpha.17, which definitely does include the change! In this version, the output from your example is: {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Root",
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "A"
}
},
"$ref": "#/$defs/SubEnum1",
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "B"
}
},
"$ref": "#/$defs/SubEnum2",
"required": [
"type"
]
}
],
"$defs": {
"SubEnum1": {
"oneOf": [
{
"type": "object",
"properties": {
"other_type": {
"type": "string",
"const": "C"
}
},
"$ref": "#/$defs/SubSchema1",
"required": [
"other_type"
]
},
{
"type": "object",
"properties": {
"other_type": {
"type": "string",
"const": "D"
}
},
"$ref": "#/$defs/SubSchema2",
"required": [
"other_type"
]
}
]
},
"SubEnum2": {
"oneOf": [
{
"type": "object",
"properties": {
"other_type": {
"type": "string",
"const": "E"
}
},
"$ref": "#/$defs/SubSchema3",
"required": [
"other_type"
]
},
{
"type": "object",
"properties": {
"other_type": {
"type": "string",
"const": "F"
}
},
"$ref": "#/$defs/SubSchema4",
"required": [
"other_type"
]
},
{
"type": "object",
"properties": {
"other_type": {
"type": "string",
"const": "G"
}
},
"required": [
"other_type"
]
},
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"other_type": {
"type": "string",
"const": "H"
}
},
"required": [
"other_type",
"id"
]
}
]
},
"SubSchema1": {
"type": "object",
"properties": {
"w": {
"type": "string"
}
},
"required": [
"w"
]
},
"SubSchema2": {
"type": "object",
"properties": {
"x": {
"type": "string"
}
},
"required": [
"x"
]
},
"SubSchema3": {
"type": "object",
"properties": {
"y": {
"type": "string"
}
},
"required": [
"y"
]
},
"SubSchema4": {
"type": "object",
"properties": {
"z": {
"type": "string"
}
},
"required": [
"z"
]
}
}
} |
Oh by the way, the schema for the |
@GREsau With regards to #355 and #347, even on the latest alpha (1.0.0-alpha.16), I'm still seeing all subschemas getting inlined.
For example, using this code as my test:
I get the following schema:
This schema does not end up with any definitions section and every model and enum other than Root is inlined. In this case also nothing is marked as
deny_unknown_fields
so it shouldn't be falling into that edge case.The text was updated successfully, but these errors were encountered: