OpenAPI Specification does not have a way to define arbitrary headers like in your example. Here is the corresponding enhancement request:
Support wildcard header/parameter
If you are designing a new API (as opposed to documenting an existing API), you can try using a single header containing comma-separated key=value
pairs, as suggested in the comments in the link above:
X-MyHeader: key1=value, key2=value, key3=value
In OpenAPI 3.0, such header can be defined as an exploded object:
# openapi: 3.0.3
parameters:
- in: header
name: X-MyHeader
schema:
type: object # Free-form object
example:
key1: value1
key2: value2
style: simple # Default (and only) style for headers, can be omitted
explode: true
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…