Closed metametadata closed 5 years ago
The same happens here, went back to alpha26.
I'm also running into this issue. I haven't been able to look into it too deeply yet, but the last succeeding versions I can find is [compojure-api "2.0.0-alpha26"]
and [metosin/spec-tools "0.8.0"]
(haven't tried higher spec-tools versions). Updating to alpha 27 triggers this issue. That makes me think that the issue is not entirely on the spec-tools side, though both libraries deserve more investigation, as it could be the new version of compojure-api is triggering the new problem in spec-tools.
It look like this part of the diff is where the issue is coming from:
https://github.com/metosin/compojure-api/compare/2.0.0-alpha26...2.0.0-alpha27 R122 (GitHub breaks the link if I include the line number). https://github.com/metosin/compojure-api/commit/67721ef774dde0372a94b72d6e3d6ced884c5598#diff-bb049ce0a1f1064262c0f0ca760fea86R124
I did some more digging with the debugger and I think I've isolated the issue a little bit further. It seems to be that https://github.com/metosin/compojure-api/blob/2.0.0-alpha27/src/compojure/api/coercion/spec.clj#L83 is returning nil
when given a Spec. However I'm uncertain if I'm interpreting the debugger correctly, it seemed a little bit flaky.
Hi. Finally had time to check this. It seems to be fixed in https://github.com/metosin/spec-tools/commit/e6041cbcc88281900765c3798d67a29f56511964 and in [metosin/compojure-api "2.0.0-alpha28"]
(on Nov 19). Tested the app, all routes work.
I'm running into this with:
[metosin/compojure-api "2.0.0-alpha28"]
[metosin/spec-tools "0.8.2"]
The spec is of the form:
(stc/spec (s/or :x :x
:y: :y
:z :z))
where :x
, :y
and :z
are map specs.
Works with:
[metosin/compojure-api "2.0.0-alpha26"]
[metosin/spec-tools "0.7.1"]
FYI, I was able to reproduce this bug in my project using [metosin/compojure-api "2.0.0-alpha30"] dependency.
As a workaround I used :
instead of
(s/def ::uuid uuid?) (s/def ::user-id ::uuid) (s/def ::user (s/keys :req-un [::user-id]))
you can do :
(def uuid-spec (st/spec {:spec uuid? :type :uuid})) (s/def ::uuid uuid-spec) (s/def ::user-id uuid-spec) (s/def ::user (s/keys :req-un [::user-id]))
Thanks, Michel
Library Version(s)
Started appearing in 2.0.0-alpha27. Presumably it's a defect in
spec-tools
dep.Problem
Library produces
AssertionError
if it stumbles upon the spec similar tofoo-result-map
in:return
or:body
(it's the minimal example I could find):Steps:
1)
git clone https://github.com/metametadata/compojure-api-2-alpha27-bug
2)lein ring server
3) In Swagger UI try outfoo-result-map
orprocess-foo-result-map
endpoint.Actual:
java.lang.AssertionError
Expected: no errors.
Stacktrace example: