ring-swagger

ring-swagger & compojure-api
ikitommi 2018-03-27T04:26:28.000122Z

@slipset I think coerce would be a good idea. It would call s/conform & s/unform to get the orignal value.

ikitommi 2018-03-27T04:28:02.000051Z

I wrote a issue into clj jira to enable coercion into spec, with single sweep. It would be easy to implement there - and fast.

ikitommi 2018-03-27T04:28:53.000082Z

https://dev.clojure.org/jira/browse/CLJ-2251

ikitommi 2018-03-27T04:34:29.000120Z

currently, we can't extend spec like this from outside (libs like spec-tools) - without copying all internals.

slipset 2018-03-27T08:19:55.000446Z

Thanks, performant or not, unform was what I was looking for.

1👍
mgrbyte 2018-03-27T13:22:12.000161Z

@ikitommi Looking at developing a PR for this now. How do you run tests? I've tried using lein test ... (perhaps that could be in a 'contributing" section of the README or something)

ikitommi 2018-03-27T13:27:28.000187Z

@mgrbyte could & should be in contributing, and it's lein midje.

mgrbyte 2018-03-27T13:28:36.000450Z

thanks :thumbsup:

mgrbyte 2018-03-27T14:36:20.000470Z

think I've found the right place to change in the tests (test19/spec_coercion-test.clj), can make it fail as expected. Have tried looking thru the code to find where this is happening, but I'm a bit lost ... I think what's happening is that it only happens for a resource (which matches my use case) and it seems to be skipping request validation since the test failure (when I annotate it with println is a response validation error:

Loading (compojure.api.coercion.spec-coercion-test)
RESPONSE VAL ERRR: ({:path [:total], :pred clojure.core/pos-int?, :val -4, :via [:compojure.api.coercion.spec-coercion-test/total], :in [:total]})

FAIL "apis - resource - parameters as specs" at (spec_coercion_test.clj:293)
Expected:
400
Actual:
500

mgrbyte 2018-03-27T15:04:24.000082Z

I've created an issue here: https://github.com/metosin/compojure-api/issues/373 Will try and look into it more when I have more time, at the moment, I can't see where the code path diverges between a plain GET route and a resource (for exception handling).