Skip to content

Instantly share code, notes, and snippets.

@ThomasVille
Created November 13, 2025 08:54
Show Gist options
  • Select an option

  • Save ThomasVille/06ebf97ed17966c6d0cb2565a89c5aa2 to your computer and use it in GitHub Desktop.

Select an option

Save ThomasVille/06ebf97ed17966c6d0cb2565a89c5aa2 to your computer and use it in GitHub Desktop.
`#[serde(tag)]` conflicts with discriminator property in nested objects
{
"openapi": "3.1.0",
"info": {
"title": "Test",
"description": "Reproduction scenario",
"version": "0.68.0"
},
"components": {
"schemas": {
"PersonResource": {
"type": "object",
"required": ["type", "id"],
"properties": {
"type": {
"type": "string",
"enum": ["person"]
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"OrganizationResource": {
"type": "object",
"required": ["type", "id"],
"properties": {
"type": {
"type": "string",
"enum": ["organization"]
},
"id": {
"type": "string"
},
"companyName": {
"type": "string"
}
}
},
"ResourceUnion": {
"oneOf": [
{
"$ref": "#/components/schemas/PersonResource"
},
{
"$ref": "#/components/schemas/OrganizationResource"
}
],
"discriminator": {
"propertyName": "type",
"mapping": {
"person": "#/components/schemas/PersonResource",
"organization": "#/components/schemas/OrganizationResource"
}
}
}
}
},
"paths": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment