Reputation: 736
I find myself repeating a description again and again within a requestbody > content. I looked for a DRY technique in the OpenAPI v3 Specification where I might use a $Ref in order to simplify things. Nothing jumped out at me. So I thought I would ask the experts here if they know a way.
Upvotes: 1
Views: 51
Reputation: 2393
Is it purely the description which repeats, or a sub-section of your requestBody content schema? If the former, you can simply break down your schema into sub-schemas and $ref
them. If the latter...
As description
is a string property not an object, it cannot be replaced by a $ref
, but you can use the allOf
schema keyword to combine schemas:
allOf:
- $ref: '#/components/schemas/myDescription'
- ... # other schema properties
and in your components/schemas
:
myDescription:
description: 'Re-usable description here'
Upvotes: 1