Fork me on GitHub
#ring-swagger
<
2018-03-24
>
ikitommi06:03:12

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

ikitommi06:03:54

@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 😉

👍 4
mgrbyte13:03:12

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

ikitommi13:03:28

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

mgrbyte13:03:36

thanks :thumbsup:

mgrbyte14:03:20

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

mgrbyte15:03:24

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

ikitommi06:03:09

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.

jmckitrick17:03:15

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