How to handle response headers? #22
Replies: 2 comments 2 replies
-
In Hyper-Schema, it was a schema and referenced the I-D that became RFC 8941 for how to map various header syntaxes into the JSON Schema data model. |
Beta Was this translation helpful? Give feedback.
-
Whatever the solution: headers (and trailers?) should be handled the same way in request (+path+api) and response. Reminder about how request and response headers are handled in V3:
That leads to the following issues:
Based on the current form of v4, having a dedicated property everywhere where headers (or trailers?) are needed looks fine (it's content would be similar to parameter schema? or using a standard as mentioned above). I've noticed in some samples the idea of using a specific property in the parameters schema for headers (along with the better idea of having a dedicated property!). parameterSchema:
type: object
properties:
header: ## We can either use this specially named property or create a first class headerSchema property on the Request Object
type: object
properties:
path:
const: service.createFoo ## path Header field used to convey the RPC method That specific property inside the parameter schema (which is completely "free") would lead to problems: what if I need a "header" query parameter? Unless all different non-body parameters are stored in a high-level "parameters" schema with property matching the existing parameter type and maybe new ones? (path, query, anchor, headers, trailers, and cookies for instance), but then why not have a fixed OpenAPI structure defining explicitly the different non-body parameters? Also that "parameter schema with some fixed properties" would possibly not be reusable in responses? (are "trailers" and "headers" response's parameters?) PS: And we shouldn't forget there's also the question of cookies (are they parameters? Or specific headers?). |
Beta Was this translation helpful? Give feedback.
-
Do we just keep that as a distinct property on the response object? Is it just a simple dictionary? What would it mean to make it a JSON Schema?
What do people do with those headers?
Beta Was this translation helpful? Give feedback.
All reactions