More Than Five
More Than Five

Reputation: 10419

Re-usable parameters in open api specification

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

Upvotes: 1

Views: 1591

Answers (1)

Alex Shum
Alex Shum

Reputation: 71

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.

Upvotes: 2

Related Questions