ring-swagger & compojure-api
ikitommi 2018-03-24T06:33:12.000052Z

@jmckitrick I think it’s about simplicity. Closure is a first class concept in FP/Clojure and people (should) understand that already. Custom restructuring is part of a DSL, which is c-api spesific. Also, the closure-based dependencies are resolved at api-creation time, and thus can be used to generate new static routes (generate crud-routes based on tables in the db). Request-time injection is both slower (injecting component into request and extracting them from there), can only create dynamic routes (not seen in swagger) and if the deps are setup incorrectly, it fails at runtime.

ikitommi 2018-03-24T06:34:54.000053Z

@mgrbyte oh, request should be 400 and response 500. Was sure there were tests for this. Could you write an Issue out of this, PR would be nice too 😉

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)

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).

ikitommi 2018-03-24T06:37:09.000009Z

haven’t hear about ‘pact’ before. Looks like basic integration tests? We ported some of the good stuff of Midje to metosin/testit, which is based on clojure.test. Have been using that for integration tests. Easy way to do partial asserts on the responses.

jmckitrick 2018-03-24T17:13:15.000093Z

@ikitommi I see your point. And I agree language concepts should be favored over app-specific concepts.