Skip to content

Idea: strict-content-type-middleware #736

@opqdonut

Description

@opqdonut

A middleware that checks that responses use one of the content-types specified under :response <status> :content. The middleware should probably return a HTTP 500 if an unknown content-type is seen.

Currently, if you specify an explicit response content-type, reitit will allow it, and won't even apply any coercion (if the content-type is not listed and there's no :content :default).

I think this is what OpenAPI users probably want: they want the OpenAPI schema to be enforced on the reitit level.

Doing this sort of checking by default would be a breaking change for many users who are not that into OpenAPI specs.

Middleware ordering needs to be thought about. This thing needs to be outside muuntaja. This can be either before or after coerce-response-middleware.

Related to #735

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions