Fork me on GitHub
#ring-swagger
<
2016-08-22
>
ikitommi07:08:39

@dkuykendall I think there is no easy way to do this currently. in Swagger, the path + method pairs are unique, so, you can’t define different parameter sets for different endpoints based on the runtime request data. The Swagger (OpenAPI 3.0) spec in under construction, it might bring some help for these.

ikitommi07:08:05

with the current c-api, you could a) make all the POST parameters optional (e.g. :body [body (s/maybe …)]) so that the coercion will not fail or you could just disable the automatic coercion, add the swagger-docs by hand and run the coercion manually after you have resolved which parameter sets to use.

ikitommi07:08:44

(POST “/my-endpoint” request
  ;; just docs
  :swagger {:parameters {:formData {(s/optional-key :x) s/Str}, :body (s/maybe {(s/optional-key :x) s/Str})}}
  ; handle request here, use fns in compojure.api.coerce to run coercion if needed
  )