This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-06
Channels
- # announcements (3)
- # beginners (83)
- # calva (11)
- # cider (24)
- # cljdoc (2)
- # cljs-dev (1)
- # clojure (216)
- # clojure-berlin (1)
- # clojure-dev (18)
- # clojure-europe (8)
- # clojure-italy (5)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (34)
- # clojure-uk (75)
- # clojuredesign-podcast (12)
- # clojurescript (33)
- # clojutre (13)
- # community-development (1)
- # core-async (38)
- # cursive (19)
- # datomic (28)
- # duct (3)
- # emacs (1)
- # events (5)
- # figwheel-main (3)
- # fulcro (93)
- # kaocha (20)
- # lambdaisland (2)
- # off-topic (40)
- # pathom (17)
- # pedestal (8)
- # quil (1)
- # re-frame (14)
- # reitit (19)
- # shadow-cljs (34)
- # sql (8)
- # tools-deps (6)
- # vim (1)
- # xtdb (8)
- # yada (18)
I'm trying to create two endpoints for my API: /users/ -> listing all users and /users/2 -> listing the user with id=2. I did the routes like posted before. This worked for me, but I can't test both endpoins using Swagger UI. What's the correct way to do this?
@rlander there is no separation of key or value either in Schema or Spec, so I don’t think there is an easy way. With schema, you can create a custom coercion-matcher, that effects maps, and transforms the keys.
there are sample in schema-tools how to create matchers that effect maps, e.g. the one that strips away extra keys not part of the Schema: https://github.com/metosin/schema-tools/blob/master/src/schema_tools/coerce.cljc#L46-L65
the matchers in Schema don’t compose that easily, there are helpers for this in schema-tools, including multi-matcher
, or-matchers
and forwarding-matcher
.
Another way is to add a custom mw/interceptor that does transforms the bodies before & after validation.
Thanks for the response, thats the aproach I ended up taking for my use case: add a middleware that transforms the bodies before and after and a "derived schema" that is just the Schema + a case transformation.
but, no easy way, but a valid case and asked a lot. Added a issue to malli
to make it easy with it. https://github.com/metosin/malli/issues/58
That would pretty much solve the issue for us, had we been using malli instead of schema 😃 We're planning on doing that sooner rather than later
welcome @prof.asoares. Why can’t you test those via swagger-ui?
hello, do people use reitit instead of secretary?
Hi, when I tried to use the swagger-ui I couldn't see the endpoint to list all users. But, I can see the two others endpoints.
Hi gents! I’m trying to add cors
interceptor to my router config and I have some problems. My interceptor
(defn cors-interceptor []
{:name ::cors
:enter
(fn [context]
(assoc context :request
(io.pedestal.http.cors/allow-origin {:creds true :allowed-origins some?})))})
then I added this interceptor https://github.com/khmelevskii/duct-pedestal-reitit/blob/master/src/duct_pedestal_reitit/router.clj#L12
but it doesn’t work. Can you help me to understand what I’m doing wrong?I need it because in prod build I have a problem with cors for swagger js files https://www.dropbox.com/s/w4fhyp0inxv02kt/Screenshot%202019-09-06%2016.06.54.png?dl=0
@y.khmelevskii there is a CORS interceptor in the Issue comment to be bundle in reitit-interceptors
at https://github.com/metosin/reitit/issues/236
thank you @ikitommi for the link. I saw it. But currently I can’t see this PR in reitit and I’m not sure how long I need to wait it. Thats why I’m going to use another way but I’m not sure how I can do it