0

I am trying to write a Open API Specification(V3) for a API that i am developing and facing issue in defining the accept header. In my spec, defining the accept header as follows:

parameters:
        - in: header
          name: Accept
          required: true
          description: Defines the media type and version of the API endpoint
          schema:
            enum:
              - 'application/vnd.iotdeviceenrollment.v1'
              - 'application/json'
            type: string

But i found out that i have used a restricted value 'Accept' as the name of a header parameter: https://apisecurity.io/encyclopedia/content/oasv3/oasconformance/bestpractices/v3-warning-parameter-header-accept

As a result of this, when i export the Open API Specification to the Azure APIM, the accept header is not visible and being ignored.

If this is the case, what is the correct way to define an accept header in the Open API Specification V3

Note: When tested with Open API SwaggerUI, i could see the accept header value in the UI preview.

Harshith R
  • 418
  • 1
  • 11
  • 31

1 Answers1

1

You do not need to define the Accept header manually. The values are derived from the keys of your mediatypeObjects.

MikeRalphson
  • 2,247
  • 2
  • 15
  • 16
  • 1
    Can you please elaborate on 'The values are derived from the keys of your mediatypeObjects.'. I'm trying to solve the same problem and trying to understand how to grab the header in my method that is generated from openApi – user2441441 Jun 10 '22 at 18:04