This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-16
Channels
- # atlanta-clojurians (1)
- # aws (1)
- # beginners (65)
- # boot (4)
- # cider (81)
- # cljs-dev (25)
- # cljsrn (27)
- # clojure (129)
- # clojure-dusseldorf (12)
- # clojure-italy (68)
- # clojure-norway (5)
- # clojure-poland (4)
- # clojure-spec (14)
- # clojure-uk (72)
- # clojurescript (144)
- # code-reviews (19)
- # copenhagen-clojurians (5)
- # cursive (16)
- # datomic (21)
- # editors (1)
- # emacs (15)
- # events (1)
- # figwheel (6)
- # fulcro (54)
- # graphql (1)
- # hoplon (24)
- # jobs (6)
- # jobs-discuss (2)
- # keechma (4)
- # leiningen (6)
- # luminus (17)
- # lumo (2)
- # off-topic (43)
- # onyx (6)
- # pedestal (2)
- # perun (2)
- # portkey (3)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (5)
- # shadow-cljs (46)
- # specter (8)
- # test-check (2)
- # testing (3)
- # vim (16)
- # yada (1)
Hi.
I’m trying to spec out an existing API, which uses structured query params like so /something?usage[gas]=123
which I expect to some through as {:usage 123}
eventually.
So far I have failed to convince compojure-api and generate a nice swagger interface for this.
This is an extract of what I have so far:
(ns schemas
(:require
[clojure.spec.alpha :as s]
[spec-tools.core :as st]
[spec-tools.spec :as spec]))
(s/def ::gas spec/int?)
(s/def ::electricity spec/int?)
(s/def ::usage
(st/spec (s/keys :opt-un [::gas ::electricity])))
;;; =---------------------------
(ns api
(:require [compojure.api.sweet :as sweet]
[energy-market.web.schemas :as schemas]
[ring.util.http-response :as http-response]
ring.util.codec))
(sweet/GET "/plan" []
:query-params [{usage :- ::schemas/usage {}}]
(http-response/ok {:usage usage}))