Forum Discussion
3 Replies
Hi sudha78,
I'm not 100% sure on what you are trying to achieve, but here's a definition showing two flavours similar to above.
openapi: 3.0.3 info: title: Simple Pets API description: |- This is a sample Pets API showcasing some `oneOf` scenarios version: 0.0.1 tags: - name: pets description: Everything about your Pets paths: /pets: get: tags: - pets summary: Get pets from catalog description: Returns a list of pets found on the server operationId: getPets responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/Pets' /animals: get: tags: - pets summary: Get pets from catalog description: Returns a list of pets found on the server operationId: getAnimals responses: '200': description: successful operation content: application/json: schema: oneOf: - $ref: '#/components/schemas/Cat1' - $ref: '#/components/schemas/Dog1' components: schemas: Dog: type: object properties: barks: type: boolean example: true likesFetch: type: boolean example: true Cat: type: object properties: meows: type: boolean example: true likesFetch: type: boolean example: false Pets: type: array items: oneOf: - $ref: '#/components/schemas/Cat' - $ref: '#/components/schemas/Dog' Animal: type: object properties: breed: type: string example: poodle Cat1: type: array items: $ref: '#/components/schemas/Animal' Dog1: type: array items: $ref: '#/components/schemas/Animal'
- sudha78New Contributor
Thanks for your reply.
The swagger definition is fine, but the problem is Response Sample(using ReDoc) is not generated for definition
1) The problem am facing for path '/pets' is, the 'Response Sample' is generated only for first option 'Cat1' and not generated for 'Dog1'2) For path '/animal', There is no Response sample generated for either 'Cat' or 'Dog'
Hi sudha78,
You're welcome. As far as I can tell both definitions are rendering fine (with and without examples) via SwaggerUI. You can try by importing either of the following into https://editor-next.swagger.io (File > Import URL):
If your problem is purely with ReDoc, then head over to https://github.com/Redocly/redoc and register and issue. They do have some open issues regarding multiple oneOf rendering.
Related Content
Recent Discussions
- 4 days ago
- 26 days ago