Fork me on GitHub
#reitit
<
2019-02-19
>
vinurs01:02:02

hello, i defined a method for token, and use the form, but it seems that swagger-ui here set tht content-type ‘application/json’

vinurs01:02:33

is that i need set something else?

ikitommi06:02:04

@haiyuan.vinurs you need to set :swagger {:consumes ["application/x-www-form-urlencoded"]} to hint the ui to accept correct type.

ikitommi06:02:45

I guess this could be done automatically if there are :form params, in the parameters-middleware?

ikitommi06:02:38

the OpenAPI3 parameter syntax would make the content-types explicit, there is an open issue out of that.

ikitommi06:02:13

@colliderwriter you can make them optional either with vanilla spec: :parameters {:query (s/keys :opt-un [::x])} or with data-spec: :parameters {:query {(ds/opt :x) int?)}}

ikitommi06:02:30

ds -> spec-tools.data-spec.

ikitommi06:02:17

lists should be ok in body, with data-specs: :parameters {:body {:x [int?], :y [{:z [int?]}]}}. with normal spec, it’s really verbose, but I think you should use s/coll-of or s/tuple. s/cat is a regexp op.

ikitommi06:02:35

hope these help.

ikitommi06:02:20

Did a Issue out of that automatic :form thing, with pointers. PR would be most welcome! https://github.com/metosin/reitit/issues/217