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
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"?
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))
}}
@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"?
looking forward! with both way, I mean - using data-specs and normal spec1 keys
syntax for optional keys
(optional keys should be documented also for plumaric schema and malli, but that’s a separate thing)
ok got it!
Funny when you join a channel to ask a question, and it’s just been answered 🙂
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]
ahh that worked
"in": "query",
"name": "network",
"description": "",
"type": "string",
"required": false
thanks
glad to help 🙂
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 😓