Forum Discussion
frankkilcommins
Staff
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'
sudha78
2 years agoNew 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'
Related Content
- 2 years ago
Recent Discussions
- 8 days ago