reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
ccann 2020-04-22T14:57:12.155700Z

Can anyone point me in the right direction for coercing a request parameter that has the inst? spec attached? We’re using json-transformer and the payload is JSON

jaime 2020-04-22T18:02:10.155900Z

Do you have the middleware and coercion in the route data? Then I think you just need to have the request header content-type to "application/json"?

firstclassfunc 2020-04-22T18:07:58.156900Z

hello all. Can't seem to find in the documentation how to declare optional query parameters by default all parameters are defined as required

{:swagger {:tags ["path"]}
          :get     {:summary    "Forward Path Search"
                    :parameters {:query {:src string? :dst string? :network string?}
                                 }
                    :handler    (fn [{{{:keys [src dst network]} :query} :parameters}]
                                  (path/path-search-handler src dst network))
                    }}

1
jaime 2020-04-23T08:28:34.169200Z

@ikitommi I'll review the docs, and see if I can contribute an example. Just for clarification, what do you mean by "in both ways"?

ikitommi 2020-04-23T08:32:58.169400Z

looking forward! with both way, I mean - using data-specs and normal spec1 keys syntax for optional keys

ikitommi 2020-04-23T08:33:54.169600Z

(optional keys should be documented also for plumaric schema and malli, but that’s a separate thing)

jaime 2020-04-23T08:56:10.169800Z

ok got it!

emil0r 2020-04-23T09:14:34.170300Z

Funny when you join a channel to ask a question, and it’s just been answered 🙂

jaime 2020-04-22T18:27:03.157Z

I'm trying to learn spec myself as well, it may not be the best solution. Assuming src and dst are required, and network as optional.

(s/def ::src string?)
(s/def ::dst string?)
(s/def ::network string?)

# Then define parameters as
{:parameters {:query (s/keys :req-un [::src ::dst] :opt-un [::network])}
EDIT: s here is
[clojure.spec.alpha :as s]

firstclassfunc 2020-04-22T18:30:43.157400Z

ahh that worked

"in": "query",
"name": "network",
"description": "",
"type": "string",
"required": false

firstclassfunc 2020-04-22T18:30:44.157600Z

thanks

jaime 2020-04-22T18:33:54.157800Z

glad to help 🙂

amarus 2020-04-22T23:13:02.159800Z

Hello! Can I use clj-ajax with reitit to get data from backend or I must use reitit on both frontend and backend? Sorry for the probably noobish question, but I'm really tired of all this frontend stuff 😓