Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Maks3w opened this issue Apr 5, 2015 · 14 comments
Closed

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

Maks3w opened this issue Apr 5, 2015 · 14 comments
Assignees

Comments

@Maks3w
Copy link
Contributor

Maks3w commented Apr 5, 2015

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.

@Maks3w
Copy link
Contributor Author

Maks3w commented Apr 5, 2015

IMO should be addressed as REQUIRED

@webron
Copy link
Member

webron commented Apr 6, 2015

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.

@webron webron self-assigned this Apr 6, 2015
@Maks3w Maks3w 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 Apr 6, 2015
@Maks3w Maks3w 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 Apr 6, 2015
@Maks3w
Copy link
Contributor Author

Maks3w commented Apr 6, 2015

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.

@webron
Copy link
Member

webron commented Apr 6, 2015

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.

@nfroidure
Copy link
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.

@Maks3w
Copy link
Contributor Author

Maks3w commented Apr 10, 2015

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

@nfroidure
Copy link
Contributor

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

@nfroidure
Copy link
Contributor

Say, minLength=1 when required ? http://json-schema.org/latest/json-schema-validation.html#anchor25

@Maks3w
Copy link
Contributor Author

Maks3w commented Apr 10, 2015

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

@arno-di-loreto
Copy link
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?

@webron
Copy link
Member

webron commented May 19, 2016

Parent: #560

@webron
Copy link
Member

webron commented Mar 3, 2017

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

@cataggar
Copy link

cataggar commented Aug 25, 2022

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:

@cataggar
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants