This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-21
Channels
- # announcements (6)
- # bangalore-clj (1)
- # beginners (46)
- # cider (21)
- # cljs-dev (30)
- # cljsjs (3)
- # clojure (131)
- # clojure-dev (20)
- # clojure-europe (2)
- # clojure-italy (12)
- # clojure-nl (11)
- # clojure-russia (4)
- # clojure-spec (55)
- # clojure-uk (57)
- # clojurebridge (1)
- # clojured (1)
- # clojurescript (55)
- # cursive (11)
- # data-science (1)
- # datomic (23)
- # duct (1)
- # emacs (1)
- # events (1)
- # figwheel-main (2)
- # fulcro (219)
- # graphql (16)
- # immutant (1)
- # jackdaw (3)
- # java (6)
- # juxt (30)
- # kaocha (8)
- # mount (3)
- # nyc (1)
- # off-topic (16)
- # pathom (48)
- # pedestal (1)
- # re-frame (71)
- # reagent (17)
- # ring-swagger (3)
- # shadow-cljs (96)
- # spacemacs (21)
- # specter (8)
- # speculative (20)
- # sql (21)
- # test-check (2)
- # tools-deps (12)
- # vim (6)
I'm having trouble getting spec working with compojure-api. I have version "2.0.0-alpha28" of compojure-api installed. The validation is working fine with Schema, but when I change :coercion :spec
to one endpoint for testing spec, the following error is thrown:
Caused by: java.lang.IllegalArgumentException: No implementation of method: :specify of protocol: #'compojure.api.coercion.spec/Specify found for class: nil
at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
at compojure.api.coercion.spec$eval19818$fn__19819$G__19809__19826.invoke(spec.clj:37)
at compojure.api.coercion.spec$fn__19877.invokeStatic(spec.clj:78)
at compojure.api.coercion.spec$fn__19877.invoke(spec.clj:78)
The code that is causing this error is:
(ns musician.instrument.api
(:require [compojure.api.sweet :as api]
[musician.instrument.db :as db]
[ring.util.http-response :as res]
[clojure.spec.alpha :as s]))
(s/def ::instruments (s/coll-of string?))
(api/defroutes routes
(api/GET "/" {user-id :identity}
:coercion :spec
:summary "Get all user's instruments"
:return ::instruments
(res/ok (db/find-instruments-of-user {:user-id user-id}))))
What am I missing here?Not sure if this is the problem you're facing but I've only seen the spec coercion applied to an entire context (like in https://github.com/metosin/compojure-api/blob/master/examples/coercion/src/example/spec.clj)