Closed aneilbaboo closed 2 years ago
I have the following schema for which I want to receive dynamic query parameters. Does anyone know how to do this?
E.g., /api/find?x=1&y=2&z=3 and receive a map in fields {:x 1, :y 2, :3}
/api/find?x=1&y=2&z=3
(ns myns (:require [schema.core :as scm])) (def myapp (api ... (GET "/find" [& fields] :return scm/Any (ok fields))
This works:
curl 'localhost:8080/api/runs/find?a=1&b=2' {"a":"1","b":"2"}%
But the Swagger UI does not provide a way to input query parameters:
I've tried many variants of the route, providing
:query [fields scm/Any]
And other things.
If I use a schema that starts with schema.core/maybe...
schema.core/maybe
(scm/defschema QueryArgs (scm/maybe (scm/cond-pre scm/Num scm/Str scm/Bool scm/Keyword scm/Uuid)))
and provide this to :query...
(GET "/find" [& fields] :return scm/Any :query [fields QueryArgs] (ok))
Swagger at least shows a box that allows me to assign several values inside another parameter, but it's not the one I want:
It produces a URL like this:
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/runs/find?schemas=a%3D1&schemas=b%3D2'
But I want
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/runs/find?a=1&b=2'
Please help!
I think you have the wrong project. You want Compojure-API.
Sorry!
I have the following schema for which I want to receive dynamic query parameters. Does anyone know how to do this?
E.g.,
/api/find?x=1&y=2&z=3
and receive a map in fields {:x 1, :y 2, :3}This works:
But the Swagger UI does not provide a way to input query parameters:![image](https://user-images.githubusercontent.com/2592723/151246569-1f27656a-71d0-4b0c-a85f-f62c0833f8d6.png)
I've tried many variants of the route, providing
And other things.
If I use a schema that starts with
schema.core/maybe
...and provide this to :query...
Swagger at least shows a box that allows me to assign several values inside another parameter, but it's not the one I want:![image](https://user-images.githubusercontent.com/2592723/151249567-7aa19917-8402-499b-8f38-e807a566b79a.png)
It produces a URL like this:
But I want
Please help!