Swagger.io / OpenAPI - How to reuse complete code blocks

Viewed 37

I have status codes from the server that keep repeating in the documentation:

responses:
    '204':
      $ref: '#/components/responses/204'
    '400':
      $ref: '#/components/responses/400'
    '401':
      $ref: '#/components/responses/401'
    '402':
      $ref: '#/components/responses/402'
    '403':
      $ref: '#/components/responses/403'
    '404': 
      $ref: '#/components/responses/404'
    '426':
      $ref: '#/components/responses/426'
    '429':
      $ref: '#/components/responses/429'

How can I use Swagger.io's OpenAPI to lay a reference so that I only have one short line at a time, example:

responses:
    $ref: '#/components/responses/defaultCodes'

And is it also possible to expand the list with "allOf"?

responses:
    allOf:
    - '200':
      $ref: '#/components/responses/200'
    - $ref: '#/components/responses/defaultCodes'

Thank you very much for your help : )

1 Answers
Related