-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Love how clean this thing looks when generating a requestBody with a complicated schema, but we ran into one particular case that didn't seem supported.
There doesn't seem to be support for nesting multiple layers of oneOf.
If you render the example below you'll see that only the oneOf at the top-level (in /example's schema object), is toggled through the "Option 1", "Option 2" drop-down for the Request Body section. The Example Request, also has a oneOf on requestBody, which isn't being presented to the user.
I'm assuming this probably isn't a quick fix, but it would be a great feature to add... Would it be possible to nest the Option 1, Option 2 concept for additional anyOf layers?
I've put together an example that tries to illustrate the issue:
{
"openapi": "3.0.0",
"info": {
"description": "Example Description",
"version": "EXAMPLE",
"title": "EXAMPLE TITLE",
},
"paths": {
"/example": {
"post": {
"tags": [
"Example Request"
],
"summary": "/example summary",
"description": "/example description",
"requestBody": {
"description": "Generic Request to be submitted",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"request",
"userID"
],
"properties": {
"request": {
"oneOf": [
"$ref": "#/components/schemas/ExampleRequest",
"$ref": "#/components/schemas/InfoRequest"
]
},
"userID": {
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
"schemas": {
"ExampleRequest": {
"type": "object",
"description": "Describe Request A or B",
"required": [
"requestBody"
],
"properties": {
"requestBody": {
"oneOf": [
"$ref": "#/components/schemas/RequestA",
"$ref": "#/components/schemas/RequestB"
]
}
}
},
"RequestA": {
"type": "object",
"description": "Description for Request A",
"required": [
"fieldA",
"fieldB"
],
"properties": {
"fieldA": {
"type": "string"
},
"fieldB": {
"type": "string"
}
}
},
"RequestB": {
"type": "object",
"description": "Description for Request B",
"required": [
"fieldC",
"fieldD"
],
"properties": {
"fieldC": {
"type": "string"
},
"fieldD": {
"type": "string"
}
}
},
"InfoRequest": {
"type": "object",
"description": "Description for Info Request",
"required": [
"fieldE",
"fieldF"
],
"properties": {
"fieldE": {
"type": "string"
},
"fieldF": {
"type": "string"
}
}
}
}
}
}