compojure-api
compojure-api copied to clipboard
expose route schemas for (test) clients
Currently there is an API which coerces a response to the json content. It would be useful for testing if the reverse mapping is also provided by default.
Example:
(deftext something-to-test
(let [entity (generate schema)
_ (db/insert! entity)
response (app request)]
(is (ok? response))
(when (ok? response) (is (= (-> response (->schema-entity schema)) entity)))))
If I understood correctly, this requires two things:
- response should contain information about the encoded format (it does already)
- response should contain the response schema (could be done, but just locally, not over http)
also, if there are custom options for the used format (e.g. JSON encoder/decoder options), they should available for the test. This can be done by using a separate Muuntaja instance.
One option (we have been using) is to use EDN/Transit in tests -> data is transferred as-is, no need to run json-coersion in tests. Would this be feasible in your case?
I'll take a look at that, although it doesn't appear to be quite what I am looking for. I'll look at it more in detail soon