Skip to content

Instantly share code, notes, and snippets.

@Nikos410
Created August 17, 2022 07:56
Show Gist options
  • Select an option

  • Save Nikos410/32ab8c734b8f9a50adee138aba623f49 to your computer and use it in GitHub Desktop.

Select an option

Save Nikos410/32ab8c734b8f9a50adee138aba623f49 to your computer and use it in GitHub Desktop.
Openapi spec with inheritance.
{
"openapi": "3.0.1",
"info": {
"title": "Example",
"version": "1"
},
"paths": {},
"components": {
"schemas": {
"BranchDto": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"AbstractUserDto": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"branch": {
"$ref": "#/components/schemas/BranchDto"
},
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"internal-authenticated": "#/components/schemas/InternalAuthenticatedUserDto",
"remote-authenticated": "#/components/schemas/RemoteAuthenticatedUserDto"
}
}
},
"InternalAuthenticatedUserDto": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractUserDto"
}
]
},
"RemoteAuthenticatedUserDto": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractUserDto"
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment