metosin/compojure-api — pull request #7 by arttuka (2014-03-14 09:11:17+00:00)
Title: Use :return parameter on a swaggered route to validate output data

The :return parameter of route macros was not used for anything except Swagger output. I added a restructuring function that uses `schema.core/validate` and the :return parameter to validate the last form in the route body. The function handles both a response map (validating :body) or a plain data structure (that another middleware converts into a response map).

JSON encoders were added for all Prismatic schema types and java.lang.Class, because when validation fails the thrown exception includes the whole failed schema, and compojure.api.middleware.ex-info-support converts it into a JSON response.