This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-01
Channels
- # announcements (20)
- # babashka (3)
- # beginners (30)
- # calva (28)
- # cider (3)
- # circleci (4)
- # clerk (27)
- # clj-kondo (72)
- # cljdoc (15)
- # cljs-dev (1)
- # clojure (85)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-spec (7)
- # clojurescript (19)
- # clr (1)
- # conjure (11)
- # datahike (2)
- # datomic (11)
- # emacs (26)
- # events (4)
- # hoplon (35)
- # hyperfiddle (41)
- # jobs (7)
- # lsp (10)
- # nrepl (3)
- # off-topic (57)
- # portal (47)
- # practicalli (1)
- # rdf (3)
- # reitit (21)
- # releases (1)
- # testing (6)
- # tools-build (16)
- # wasm (1)
- # xtdb (16)
I was surprised to find that coerced query-params
use strings as keys instead of keywords like body-params
. Is there configuration available to change that?
;; Global route Configuration - coersion and middleware applied to all routes
(def router-configuration
"Reitit configuration of coercion, data format transformation and middleware for all routing"
{:data {:coercion reitit.coercion.spec/coercion
:muuntaja muuntaja/instance
:middleware [;; swagger feature for OpenAPI documentation
api-docs/swagger-feature
;; query-params & form-params
parameters/parameters-middleware
;; content-negotiation
middleware-muuntaja/format-middleware
;; coercing response body
coercion/coerce-response-middleware
;; coercing request parameters
coercion/coerce-request-middleware
;; Pretty print exceptions
coercion/coerce-exceptions-middleware
;; logging with mulog
[middleware-arqivist/wrap-trace-events :trace-events]]}
;; pretty-print reitit exceptions for human consumptions
:exception pretty/exception})
this is my middleware stack (I have coerce-request-middleware
in there)My coercion is reitit.coercion.malli
. But that shouldn't affect this particular thing, I think.
The impl of coerce-request-middleware
is straightforward, so perhaps you could debug it to see why you don't have :parameters
in there. Just in case -
middleware transform is great for stuff like this.
Is there a chance that that particular resource where you checked that key overrides the coercion?
not that I can see
["/redirect"
{:swagger {:externalDocs
{:description "Slack OAuthV2 docs"
:url ""}}
:get
{:summary "OAuth2 redirect target"
:description "This endpoint receives the data about the workspace, after a user successfully added the app to their account."
:parameters {:query-params ::specs/oauth-redirect}
:responses {200 {:body string?}
500 {:body string?}}
:handler (handlers/oauth-redirect system)}}]
route definition looks pretty standard to me, no special middleware applied to itNah, that's what I meant.
But also, I specify my parameters differently - I'd write that as :parameters {:query ...}
. But given the code of the coercing middleware, it shouldn't affect anything.
interesting, I can't use :query
there at all
Execution error (AssertionError) at spec-tools.core/create-spec (core.cljc:536).
Assert failed: Unable to resolve spec: :jcpsantiago.arqivist.api.slack.specs/oauth-redirect
works fine with query-params
though (except for the strings, but it looks to me as if it's happening by design)☝️ I only changed :query-params
to :query
, nothing else. No changes to the spec namespace etc
It actually might be related, if the :parameters
key is there and has value nil
.
It would mean that the coercer just doesn't work - it returns nil
. I don't know how the Spec coercer works so can't tell but maybe it looks for the :query
key which doesn't work for you.
Oh, can you check whether that spec is getting any use at all? E.g. feed some wrong data to the endpoint and see if it reports it.
If you see that the spec ends up not being used, try resolving that keyword spec manually and passing the spec object itself.
got it! great debugging help @U2FRKM4TW! classic typo xD oath
instead of oauth
in the spec name! :melting_face:
now i'm getting a :parameters
key with the expected keywordized map. Thanks!