reitit icon indicating copy to clipboard operation
reitit copied to clipboard

Support headers coercion in ring responses

Open ccann opened this issue 5 years ago • 2 comments

It would be nice to be able to validate/coerce headers in ring responses like so:

    ["authorize"
     {:name ::authorize
      :get {:responses {302 {:headers {:location url?}}}
            :parameters {:query authorize-params}
            :handler (authorize! origin)}}

Unless this is this already supported and my syntax incorrect? I also tried {:headers {"Location" url?}}

The docs do seem to suggest only :body is supported:

Responses are defined in route data under :responses key. It’s value should be a map of http status code to a map which can contain :body key with Coercion Schema as value.

ccann avatar Oct 16 '19 20:10 ccann

le bump

This also affects Swagger UI, if I'm not mistaken? I'm using Malli coercion, and if I try something like the above I get a single header listed whose name is just "1":

image

Looking at the code, I think it's just not transforming the schema for :headers

WhittlesJr avatar Feb 09 '22 15:02 WhittlesJr

le bump encore

I also have a Location header that I would like documented for a 201 resource created response.

I'm wondering what the correct syntax should be, for a time when this might be supported in the future (so that I can add it now in anticipation of it working some day).

scottlowe avatar Jun 21 '23 22:06 scottlowe