Skip to content

Set the "Accept" request header to the specified type, rathern than a…#290

Draft
Numpsy wants to merge 1 commit intofsprojects:masterfrom
Numpsy:accepts_mime
Draft

Set the "Accept" request header to the specified type, rathern than a…#290
Numpsy wants to merge 1 commit intofsprojects:masterfrom
Numpsy:accepts_mime

Conversation

@Numpsy
Copy link
Contributor

@Numpsy Numpsy commented Feb 9, 2026

…lways ApplicationJson

When doing some tests with a client for an API that returns plain text, I noticed that the Accept header on SwaggerProvider requests always seemed to be set to application/json rather than the text type specified in the OpenApi spec, and then I saw this checking if retMime is specified but then always using ApplicationJson and wondered if that's correct?

If this is an issue then maybe it could also be tested with something like

[<Route("api/[controller]")>]
[<ApiController>]
type ReturnCsvController() =
    inherit ControllerBase()

    [<HttpGet; Produces("text/csv")>]
    member this.Get() =
        if this.Request.Headers.Accept.Equals("text/csv") then
            "Hello,world" |> ActionResult<string>
        else
            ActionResult<string>(UnsupportedMediaTypeResult())

?

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

Successfully merging this pull request may close these issues.

1 participant