-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
How to state parameter requirements in HTTP headers? #2458
Comments
If the Content-Disposition will be manually passed in by devs, how about setting it as type string in parameter.schema.type and set required to true in parameter.required. You could also add a regex pattern in parameter.schema.pattern that must pass for the value of Content-Disposition that describes the filename value as a string with length > 0. Don't forget to include the body description like so.
|
This doesn't match the request, however. requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
profileImage:
type: string
format: binary
encoding:
profileImage: # Property name
contentType: application/octet-stream
headers: # Custom headers
Content-Disposition:
description: part's filename
style: matrix
explode: true
schema:
type: object
required:
- form-data
- name
- filename
properties:
form-data:
const: ''
name:
description: part name
type: string
filename:
description: name of file to be created
type: string RFC 6570 says
However, this will put a |
@lmmarsano unfortunately, there's no clear mapping from schemas or parameter styles into HTTP headers, in part because the syntax is pretty inconsistent across different headers. I think the best you could do would be to treat it as a string and use a regex 😕 |
This issue has been labeled with |
@handrews While I agree it's a challenge, it's not entirely inconsistent.
Regex complexity to account for these rules can be considerable.
For clearer, more maintainable specs, I wonder about interest in making the language more aware of the http spec on headers.
While I understand OpenAPI specs largely serve http APIs with JSON payloads, the introduction states it's for http APIs generally, and this seems the logical place for rules in the http spec. If the interest exists, I also wonder how we might best approach that
|
@lmmarsano I had actually been thinking about leveraging the rules for the common cases (RFCs 8941 and 9110) and having an extension registry for mechanisms to support more unusual cases. We can keep discussing headers here to see if there is something that might fit in OAS 3.2 (possibly leveraging the registries). For the bigger-picture questions of modularity and extension, I would recommend looking at the Moonwalk discussions, where we are discussing breaking changes for the next major OAS release. |
Cool, I didn't know about moonwalk. Based on the participation guidelines, a draft feature in the registry you suggested makes sense. RFC 8941 is stricter and more structured, so it might be preferable.
|
For HTTP dates, yeah we'd need to add a I think that RFC 8941 would be handled one way (with one set of This would be for 3.2 (at the earliest), so there's some time to think about this while we focus on getting 3.0.4 and 3.1.1 out the door. |
FYI: RFC 9651 has obsoleted RFC 8941.
|
For example, as described in the guide, in a request such as
how would a spec state that the
filename
parameter in headerContent-Disposition
is required and explain special usage in a description?RFCs state that the filename parameter is optional.
It's not clear how to express parameters for a header object.
The text was updated successfully, but these errors were encountered: