metosin / compojure-api

Sweet web apis with Compojure & Swagger
http://metosin.github.io/compojure-api/doc/
Eclipse Public License 1.0
1.11k stars 149 forks source link

Spec-Coercion for return type reverses LazySeqs #412

Closed Wegi closed 5 years ago

Wegi commented 5 years ago

Library Version(s)

2.0.0-alpha28

Problem

When spec-coercion for the :return type is activated and a lazy sequence is passed as the result, the sequence is reversed. Does not happen with a e.g. vector.

Example:

(GET "/numbers"
  :query-params []
  :return ::any-matching-spec
  (map inc [1 2 3 4]))

If you open the swagger API and go to that endpoint the result will be "[5 4 3 2]". When replacing map with mapv to get a nonLazy Sequence or when removing the :return the result is "[2 3 4 5]" as it should be.

This bug reverses all lazy sequences, even if they are nested inside of multiple levels of maps.

danielcompton commented 5 years ago

Is this a dupe of #406?

Wegi commented 5 years ago

Oh yeah, thanks seems like it. I'll close this one again.

ikitommi commented 5 years ago

I'll try to cut out a new version of spec-tools + c-api. This will be fixed in it too: https://github.com/metosin/spec-tools/issues/165