You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we use example as well examples object together?
Can we partially edit examples like in schema properties.
Sorry had to ask, had been reading specs but coudn't understand. Would be willing to create and add this to examples since this is very important to keep your specs DRY.
/pets/{petId}:
get:
summary: Info for a specific petoperationId: showPetByIdtags:
- petsparameters:
- name: petIdin: pathrequired: truedescription: The id of the pet to retrieveschema:
type: stringresponses:
'200':
description: Expected response to a valid requestcontent:
application/json:
schema:
$ref: "#/components/schemas/Pets"examples:
all_pets:
$ref: "#/components/examples/AllPets"all_pets1:
$ref: "#/components/examples/AllPets1"cats:
$ref: "#/components/examples/CatPets"components:
schemas:
Pet:
required:
- id
- nameproperties:
id:
type: integerformat: int64name:
type: stringtag:
type: stringPets:
type: arrayitems:
$ref: "#/components/schemas/Pet"examples:
Dog:
value:
id: 1name: "Dog"tag: "dog"Cat:
value:
id: 2name: "Cat"tag: "cat"AllPets:
summary: "Array of pets"value:
- $ref: "#/components/examples/Dog"
- $ref: "#/components/examples/Cat"CatPets:
summary: "Only Cats"value:
- $ref: "#/components/examples/Cat"AllPets1:
- id: 1name: "Dog"tag: "dog"
- id: 2name: "Cat"tag: "cat"
The text was updated successfully, but these errors were encountered:
Swagger UI omits examples and hence I cannot validate above spec is correct or not. Ideally I guess many people would like to reference examples to create other examples, or overriding them.
Yes, you can reference examples, example (singular) is for use inside schemas, while examples (plural) is for use elsewhere in the OAS document, and no you can't use both eno you cannot edit the examples in the process of referencing them.
I think this covers everything, and given the age of the question I'm going to go ahead and close this. Please re-open or open a new issue if you have further questions.
I stumbled on a nice blog post just after reading this thread. I know this issue is closed, but I ended up here anyway after searching so I thought I'd drop a link to the blog post for anyone else who comes here for the same info.
Regarding OAS3:
Sorry had to ask, had been reading specs but coudn't understand. Would be willing to create and add this to examples since this is very important to keep your specs DRY.
The text was updated successfully, but these errors were encountered: