swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Header annotation doesn't fully support OAS 3.0

Open christophejan opened this issue 2 years ago • 1 comments

Currently, all 3.x.x versions of OpenAPI Specification define Header object as :

The Header Object follows the structure of the Parameter Object with the following changes:

  1. name MUST NOT be specified, it is given in the corresponding headers map.
  2. in MUST NOT be specified, it is implicitly in header.
  3. All traits that are affected by the location MUST be applicable to a location of header (for example, style).

But current swagger-core Header annotation seems to have a lot of missing attributes when I compare it to Parameter annotation :

I think all the matching Parameter object fields can't be defined currently on response header through swagger annotations, but should.

christophejan avatar Jun 04 '22 01:06 christophejan

christophejan avatar Jun 04 '22 14:06 christophejan

Due to openapi spec there is no reason to add most of mentioned fields:

allowEmptyValue – valid only for query parameters

style – ‘header’ style is always set to simple, we don’t need that annotation then

allowReserved – this property only applies to parameters with “in” value of “query”, so it’s also not applicable as it’s header

We decided to take a deeper look on other missing fields like: explode, array, hidden, example, examples.

These were added by https://github.com/swagger-api/swagger-core/pull/4608

micryc avatar Feb 01 '24 13:02 micryc