Created
May 8, 2024 14:34
-
-
Save rei-ber/d93abc83f7dbabb5ff673517cfc4d4a6 to your computer and use it in GitHub Desktop.
anyOf openapi spec example (works for openapi-generator)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"components": { | |
"schemas": { | |
"Reputation": { | |
"properties": { | |
"fieldref": { | |
"title": "Fieldref", | |
"type": "string" | |
}, | |
"mark": { | |
"title": "Mark", | |
"type": "string" | |
}, | |
"ttl": { | |
"title": "Ttl", | |
"type": "integer" | |
} | |
}, | |
"required": [ | |
"fieldref", | |
"mark", | |
"ttl" | |
], | |
"title": "Reputation", | |
"type": "object" | |
}, | |
"UsecaseData": { | |
"properties": { | |
"reputation": { | |
"anyOf": [ | |
{ | |
"$ref": "#/components/schemas/Reputation" | |
}, | |
{ | |
"type": "null" | |
} | |
], | |
"default": null | |
} | |
}, | |
"required": [], | |
"title": "UsecaseData", | |
"type": "object" | |
} | |
} | |
}, | |
"info": { | |
"title": "anyof example", | |
"version": "v1" | |
}, | |
"openapi": "3.1.0", | |
"paths": { | |
"/api/v1/usecases": { | |
"post": { | |
"description": "", | |
"operationId": "post_post_usecase", | |
"parameters": [], | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"properties": { | |
"reputation": { | |
"anyOf": [ | |
{ | |
"$ref": "#/components/schemas/Reputation" | |
}, | |
{ | |
"type": "null" | |
} | |
], | |
"default": null | |
} | |
}, | |
"required": [ | |
], | |
"title": "UsecaseData", | |
"type": "object" | |
} | |
} | |
} | |
}, | |
"responses": { | |
"201": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"properties": { | |
"reputation": { | |
"anyOf": [ | |
{ | |
"$ref": "#/components/schemas/Reputation" | |
}, | |
{ | |
"type": "null" | |
} | |
], | |
"default": null | |
} | |
}, | |
"required": [ | |
], | |
"title": "UsecaseData", | |
"type": "object" | |
} | |
} | |
}, | |
"description": "" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment