Skip to content

Clarify if header is required to be sent in the response #321

Closed

Description

@Maks3w

Given the headers section has a definition for a given header (let's say ETag) the question is:

Is the header required to be present in the response sent by the server?

headers: A list of headers that are sent with the response.
https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#fixed-fields-10

Headers object: Lists the headers that can be sent as part of a response.
https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#headersObject

Reading the first definition I understand that is REQUIRED.
Reading the second definition I understand that is OPTIONAL.

Spec should be rephrased clarifying this aspect.

Activity

  1. Maks3w commented on Apr 5, 2015

    @Maks3w
    ContributorAuthor

    IMO should be addressed as REQUIRED

  2. webron commented on Apr 6, 2015

    @webron
    Member

    That's an interesting and fair question. I'll have to dig into the discussions about it to see if we mentioned anything specific about it. However, even the first definition doesn't necessarily mean it is required, but rather suggested. Normally, when something is required, the term MUST is normally used across the spec to mention something is REQUIRED. However, I agree it is not clear enough and should be revised.

  3. self-assigned this
    on Apr 6, 2015
  4. changed the title [-]Acalaration about if header is required to be sent in the response[/-] [+]Aclaration about if header is required to be sent in the response[/+] on Apr 6, 2015
  5. changed the title [-]Aclaration about if header is required to be sent in the response[/-] [+]Clarify if header is required to be sent in the response[/+] on Apr 6, 2015
  6. Maks3w commented on Apr 6, 2015

    @Maks3w
    ContributorAuthor

    The argument which I think MUST be REQUIRED is that the header is linked to the response HTTP Code.

    So it's specific enough to assume these headers will be received always for this HTTP Code.

  7. webron commented on Apr 6, 2015

    @webron
    Member

    I'm not disagreeing, but if the intent wasn't clarified originally, I may not be able to clarify it in this version of the spec as well. The current wording implies OPTIONAL over REQUIRED, but as said, I'll look into it.

  8. nfroidure commented on Apr 10, 2015

    @nfroidure
    Contributor

    What about a required=true attribute in the headers object definition?
    https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#headersObject

    I think it strongly depends on each headers type.

  9. Maks3w commented on Apr 10, 2015

    @Maks3w
    ContributorAuthor

    I only suggest when possible use the same validation rules as JSON-Schema. required: boolean is not a valid attribute.

  10. nfroidure commented on Apr 10, 2015

    @nfroidure
    Contributor

    Wasn't aware of the JSON-Schema compliance, but any property indicating the requirement would be great as well.

  11. nfroidure commented on Apr 10, 2015

    @nfroidure
    Contributor
  12. Maks3w commented on Apr 10, 2015

    @Maks3w
    ContributorAuthor

    minLength and the rest of those validators are related with the value. i.e if the header value has a minLengh of 1.

  13. arno-di-loreto commented on May 11, 2016

    @arno-di-loreto
    Contributor

    Totally agree with @nfroidure proposal (add a required property in header object).
    We already have that for parameters (headers and non body parameters objects have a lot in common) , why couldn't we have the same thing on returned headers?

  14. webron commented on May 19, 2016

    @webron
    Member

    Parent: #560

  15. webron commented on Mar 3, 2017

    @webron
    Member

    The Header Object now follows a similar pattern to the Parameter Object and contains a required field which is by default false.

  16. cataggar commented on Aug 25, 2022

    @cataggar

    The Header Object now follows a similar pattern to the Parameter Object and contains a required field which is by default false.

    @webron, https://swagger.io/specification/v2/ does not show that the Header Object has a required field like Parameter Object. It would be great if it did. I didn't find very many results in my initial search for examples:

  17. cataggar commented on Aug 25, 2022

    @cataggar

    In the currently spec, a Header Object includes it as it is almost the exact same as a Parameter Object.
    https://spec.openapis.org/oas/latest.html#header-object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions