Issue
In a openapi 3.0.0 yaml file, is it possible to reference a list of common request headers that are used in each call rather than specifying them again and again on each call?
/some-path:
get:
summary: "sample1"
operationId: doWork
description: 'description of do work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- in: header
name: Correlation-Id
schema:
type: string
format: uuid
required: true
/some-other-path:
get:
summary: "sample2"
operationId: doOtherWork
description: 'description of do other work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- in: header
name: Correlation-Id
schema:
type: string
format: uuid
required: true
i tried duplicating it.......and it works......but it is ugly as hell.
Solution
This may not be the answer you want. With version 3.0.3, we do something like the following:
openapi: 3.0.3
paths:
/some-path:
get:
summary: "sample1"
operationId: doWork
description: 'description of do work'
parameters:
...
- in: header
name: Authorization
schema:
type: string
required: true
- in: header
name: Consumer-Key
schema:
type: string
required: true
- $ref: '#/components/parameters/__common__correlationId_header'
components:
parameters:
__common__correlationId_header:
in: header
name: Correlation-Id
description: common correlation id.
required: true
schema:
type: string
format: uuid
Answered By - DwB
Answer Checked By - Willingham (JavaFixing Volunteer)