-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
According to OpenAPI Guide: Describing Parameters, certain HTTP headers are disallowed from being documented as parameters of operations:
Note: Header parameters named
Accept,Content-TypeandAuthorizationare not allowed.
Instead, they should be documented elsewhere (responses.<code>.content.<media-type>, requestBody.content.<media-type>/responses.<code>.content.<media-type> and securitySchemes/ security respectively).
Endpoints using [FromHeader(Name = "{name}")] to bind any parameters have these parameters included in the endpoint documentation, violating this requirement.
Expected Behavior
Header parameters for Accept, Content-Type and Authorization are not included in operations' parameters.
Steps To Reproduce
Define an HTTP endpoint similar to the following:
app.MapGet((
[FromHeader(Name = "Accept")] string accept,
[FromHeader(Name = "Authorization")] string authorization,
[FromHeader(Name = "Content-Type")] string contentType) =>
{
// ...
});Exceptions (if any)
No response
.NET Version
9.0.100-rc.1.24413.1
Anything else?
Spotted after looking into domaindrivendev/Swashbuckle.AspNetCore#3024 (comment), which then reminded me that in an application of my own the Authorization parameter had re-appeared after migrating to OpenAPI from Swashbuckle.AspNetCore (OpenAPI document diff Swashbuckle.AspNetCore 6.7.0 to M.A.OpenApi 9.0-preview.7).