@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.
@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 😉
@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)
@mgrbyte could & should be in contributing, and it's lein midje
.
thanks :thumbsup:
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
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).
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.
@ikitommi I see your point. And I agree language concepts should be favored over app-specific concepts.