Swagger not rendering multiple schemas
Below is a piece of code from a GET endpoint. The endpoint will return one of the schemas based on the 'subject' which is an input parameter to the endpoint.
I want to display both the schemas and their field's definitions with example under defined response section on the documentation page. But I am not able to do that. My code shows below line:
array[]
The content depends on the subject.
discriminator: {"propertyName":"subject","mapping":
{"Schema_01":"#/components/schemas/Schema1","Schema_02":"#/components/schemas/Schema2"}}
......
content:
description: The content depends on the subject.
type: array
items:
oneOf:
- $ref: '#/components/schemas/Schema1'
- $ref: '#/components/schemas/Schema2'
discriminator:
propertyName: subject
mapping:
Schema_01: '#/components/schemas/Schema1'
Schema_02: '#/components/schemas/Schema2'
........
Here are the schemas:
components:
schemas:
Schema1:
description: The content and the structure depends on the subject.
type: object
required:
- subject
properties:
subject:
type: string
........
Schema2:
description: The content and the structure depends on the subject.
type: object
required:
- subject
properties:
subject:
type: string
Please help me fix this.