Skip to content

Support content type negotiation #36

@bessgeor

Description

@bessgeor

OpenAPI spec allows to define different types for different content types.
It would be nice to generate something like that for this case:

type SomeMethodBodyInput =
  | SomeMethodBodyJson of SomeMethodJsonBodyInput
  | SomeMethodBodyFormUrlEncoded of SomeMethodFormUrlEncodedBodyInput
//...
match ctx.Request.Headers.ContentType with
| "text/json" ->
  let! json = ctx.bindJsonAsync<SomeMethodJsonBodyInput>()
  json
  //...
  |> SomeMethodBodyJson
  |> Ok
//...
| unsupported -> UnsupportedBodyContentType unsupported |> BodyBindingError |> Error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions