This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-17
Channels
- # beginners (52)
- # boot (116)
- # cider (21)
- # cljs-dev (44)
- # clojure (104)
- # clojure-dev (82)
- # clojure-greece (5)
- # clojure-japan (4)
- # clojure-nl (14)
- # clojure-russia (65)
- # clojure-serbia (3)
- # clojure-spec (38)
- # clojure-uk (9)
- # clojure-ukraine (1)
- # clojurescript (65)
- # clojurewest (1)
- # community-development (1)
- # core-logic (3)
- # cursive (5)
- # data-science (9)
- # datomic (13)
- # emacs (45)
- # euroclojure (1)
- # hoplon (2)
- # instaparse (23)
- # javascript (1)
- # jobs (2)
- # klipse (43)
- # leiningen (8)
- # lumo (25)
- # off-topic (7)
- # om (13)
- # om-next (3)
- # onyx (11)
- # pedestal (12)
- # planck (19)
- # proton (1)
- # re-frame (26)
- # reagent (26)
- # remote-jobs (13)
- # ring-swagger (23)
- # spacemacs (1)
- # untangled (3)
hi, I'm writing a test for my compojure-api app, and I am a little stumped... I have
(deftest dummy-test
(let [request (-> (mock/request :post "/foo")
(mock/body (json/generate-string foo-request))
(mock/header "jwt" valid-jwt))
response (dummy-app request)
(is (= 200 (:status response)))))
But the status is 400, with the error: {"errors" "(not (map? nil))"}@mrchance I'm not sure what could be done with that. Maybe a configurable dev-middleware which one could use to inspect request & response? Open to ideas .
Yes, not sure how to improve on that either, maybe something like "Content type missing, interpreted as Text/Plain, couldn't parse into map", at least in dev...
I have a POST with query params like {:a [{:b 1} {:b 2}]}
and I'd like to define my schema so that the Swagger UI explains the format of each map in the sequence. But it seems that I have to define the query as one schema and the maps or list of maps as another schema, and that second one is referred to in the UI under "Data Type" as simply "Array[AMap]" instead of describing the format of AMap. Am I missing something in either Schema or ring-swagger?
@daveliepmann the swagger spec doesn’t understand nested query-params, for body-params (`:body [params MultipleMaps]`) it shows them correctly
also, the (s/defschema MultipleMaps {:a [{:b s/Str}]})
works with body-params with ring-swagger.
for query-params
, it doesn’t work. It’s between a bug and a feature. Should work (as a code) but not (by the spec?).
(POST "/multiplemaps" []
:body [params MultipleMaps]
:return {:params MultipleMaps}
(ok {:params params}))
@ikitommi Thank you—`body [params...` should be a viable path for me. However I don't quite understand why the schema doesn't work for query-params. Do you mean that it is an invalid query?
sorry, not your fault - it’s a ~bug in ring-swagger, it doesn’t seem to emit swagger-spec out of :query-params
which have anonymous nested classes. If you need it, please write an issue to github for it.
but you solution of using the named inner Schema should work ok. Just renders funnily.
I think body-params is the most correct and, as you said, works like a charm, so I'll run with that
Hi, I am trying to enforce a permissions check on every endpoint. My approach was to write a middleware wrapping all of the compojure api app that returns unauthorized unless there is a ::verified or something in the response, put in there via a middleware provided by a custom metadata handler that also defines the required permissions. The problem is that invalid requests bypass this and the resource returns 401 where it should be 400. Any good ideas how to solve this nicely?