-
Notifications
You must be signed in to change notification settings - Fork 60
API Design Guidelines and the Inclusion of Headers in the API Specification #124
Comments
Hi Eric!, Relative to de essential standard headers, totally agree following OAS3 definitions. Relative to Only custom headers essential for the operation of the API be explicitly defined within the API specification, I'm not agree with that affirmation, because an API contract should be idempotent, I mean that when dev people take API contract to implement it, they shouldn't need check any other document to understand all the fields involved. |
Hi Rubén Probably we need some agreement on what an "essential" header is. I tested our implementation of the QoD API, and found that it failed if I did not include any of the following headers:
Maybe other implementations are different. Now Authorization and Content-Type should not be included in the API specification according to OAS rules (or, rather, if included, they will be ignored). But I've not seen an API specification that includes Content-Length or Host explicitly either. Rather, it is implicitly assumed that developers know how to use these standard headers (and most tooling appears to generate them automatically anyway). So my view is that any standard header included in the API Design Guidelines (essential or not) should not explicitly be included in the API specification because it is assumed that developers know how to use standard headers (having said that, the API Design Guidelines do not currently mention the Host header, so a PR is required for that). But there may be exceptions. There may be APIs that require a header that might normally be considered optional, or use a header in an unexpected way. The rule could be that standard headers should not be explicitly listed unless they are being used in a "non-standard" way by the API. |
Hi, I think we should distinguish between
Some of these proprietary headers may be transversal to all CAMARA APIs, but we should define them within each API spec, or at least have a $ref within each spec to a common place where common stuff is defined. |
@jlurien My instinct is still to leave such "helper headers" in the design guidelines and put a link to those in the API specification itself. But these are only two headers, so not a great burden to add explicitly. If the number of proprietary but non-essential headers increased however, API specifications might start to get cluttered. |
I totally agree with Eric |
Added change on PR #161 |
Thanks @RubenBG7 for taking on this PR. Can you expand it to include the following additional information?
|
Can someone explain how the chapters "3.5 HTTP Headers Definition" and "9. Architecture Headers" relates to each other? Chapter 3.x looks for me more like a tutorial about HTTP (lacking references), but I have difficulties to read guidelines out of it. From the table in chapter 9 I can't read a guidance as the columns "required" and the new column "required on swagger" are not defined. The complete document is never referring concrete to OpenAPI Spec nor has the term "swagger" as a potential synonym to OpenAPI Spec been used before chapter 9 in the document. In general the document is lacking references, starting with the pictures in "2.1 Domain Driven Design" and ending with relevant important standards to be adhered (like OpenAPI Spec). |
@hdamker Now my interpretation of Section 9 is maybe challenged by the inclusion of So that leaves But that is not the purpose of this issue or associated PR. The reason I originally raised this issue was to get an agreement on which headers should explicitly be included in OAS API definition files. And the answer is "None of the headers listed in the API Design Guidelines". |
I agree with the proposal by @eric-murray |
Fully agree here with you @eric-murray. It would be great to see a PR with the concrete changes that you have proposed above. |
Added comments and settings to the #161 |
Thanks @RubenBG7 I did some additional updates to the PR for Section 3.5, as discussed above. A question on |
Solved by PR #161 |
The API Design Guidelines list many possible headers that can be included in an API request and/or response. Some recommendations and requirements about the use of headers is included, but no guidance about how headers should be captured within the Open API Specification itself.
The OAS specification itself only has one requirement on the inclusion of headers:
In other words, use of the "Accept", "Content-Type" and "Authorization" is so well understood, that there is no point in explicitly including them because all you will do is introduce the possibility of confusion.
Currently, CAMARA API specifications are taking different approaches to the specification of headers. I think a common approach should be agreed, and I think that should be a minimalist approach. Specifically:
If we can agree on this approach, then I'll propose an update to the API Design Guidelines which clarify how headers should be treated within the API specification itself.
The text was updated successfully, but these errors were encountered: