1

I have an endpoint which takes an X-Request-ID header. This is described as:

parameters:
    - in: header
      name: X-Request-ID
      schema:
        type: string
        format: uuid
      required: true

However, if I have ten endpoints that take this header, do I have to keep repeating this or is there anyway I can get some re-use?

Thanks

More Than Five
  • 9,959
  • 21
  • 77
  • 127
  • 2
    Does this answer your question? [Swagger/OpenAPI - use $ref to pass a reusable defined parameter](https://stackoverflow.com/questions/27005105/swagger-openapi-use-ref-to-pass-a-reusable-defined-parameter) – Helen Mar 27 '20 at 12:00

1 Answers1

2

To add to Helen's comment, you can achieve some reuse by defining X-Request-ID as a Parameter Object in the Parameters Definitions Object, then reference it (by using a Reference Object) in the parameters field of each Path Item Object to denote that it's applicable to all operations under the path.

Alex Shum
  • 71
  • 1