{"action":"created","issue":{"url":"https://api.github.com/repos/metosin/compojure-api/issues/121","labels_url":"https://api.github.com/repos/metosin/compojure-api/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/metosin/compojure-api/issues/121/comments","events_url":"https://api.github.com/repos/metosin/compojure-api/issues/121/events","html_url":"https://github.com/metosin/compojure-api/issues/121","id":83541455,"number":121,"title":"Api-level override for coercers","user":{"login":"ikitommi","id":567532,"avatar_url":"https://avatars.githubusercontent.com/u/567532?v=3","gravatar_id":"","url":"https://api.github.com/users/ikitommi","html_url":"https://github.com/ikitommi","followers_url":"https://api.github.com/users/ikitommi/followers","following_url":"https://api.github.com/users/ikitommi/following{/other_user}","gists_url":"https://api.github.com/users/ikitommi/gists{/gist_id}","starred_url":"https://api.github.com/users/ikitommi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikitommi/subscriptions","organizations_url":"https://api.github.com/users/ikitommi/orgs","repos_url":"https://api.github.com/users/ikitommi/repos","events_url":"https://api.github.com/users/ikitommi/events{/privacy}","received_events_url":"https://api.github.com/users/ikitommi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/metosin/compojure-api/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-01T14:51:59Z","updated_at":"2015-06-07T21:13:07Z","closed_at":null,"body":"Applying json-coercion for all transports is a bad idea. XML needs extra forwarding-coersion to handle sequence schemas, with Transit we should not do any coercions.\r\n\r\n```clojure\r\n(api\r\n   {:options {:coercer-provider-fn my-coercer-provider}}\r\n   (context* \"/api\" [] ...)\r\n```\r\n\r\n`coercer-provider-fn` would be a function `[request, coercion-type] -> coercer-fn`. So, at runtime, we could select the coercer based on any request attributes (transport etc) or we could ignore the whole coercion `(constantly identity)`."},"comment":{"url":"https://api.github.com/repos/metosin/compojure-api/issues/comments/109800045","html_url":"https://github.com/metosin/compojure-api/issues/121#issuecomment-109800045","issue_url":"https://api.github.com/repos/metosin/compojure-api/issues/121","id":109800045,"user":{"login":"ikitommi","id":567532,"avatar_url":"https://avatars.githubusercontent.com/u/567532?v=3","gravatar_id":"","url":"https://api.github.com/users/ikitommi","html_url":"https://github.com/ikitommi","followers_url":"https://api.github.com/users/ikitommi/followers","following_url":"https://api.github.com/users/ikitommi/following{/other_user}","gists_url":"https://api.github.com/users/ikitommi/gists{/gist_id}","starred_url":"https://api.github.com/users/ikitommi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikitommi/subscriptions","organizations_url":"https://api.github.com/users/ikitommi/orgs","repos_url":"https://api.github.com/users/ikitommi/repos","events_url":"https://api.github.com/users/ikitommi/events{/privacy}","received_events_url":"https://api.github.com/users/ikitommi/received_events","type":"User","site_admin":false},"created_at":"2015-06-07T21:13:07Z","updated_at":"2015-06-07T21:13:07Z","body":"oli hyvä viikonloppu ;)\r\n\r\nGave this a though.\r\n\r\nAs you noticed, the current coercion is tightly coupled into the generated code. Despite disabling the api-level coercion, let generated `letk`s will still fail for missing keys. Disabling the return body coercion can be done with api-level override (I believe without any modifications to the `restructure` fn).\r\n\r\nIf you need to bypass both the input schema coercion & `letk` codes (and push the logic into a inner function), I think it could be better not to use the currently shipped metadata handlers from compojure-api.\r\n\r\nDo you just need the swagger-docs out of c-api? If so, we could push a new `:swagger` restructuring just for docs. Would consume the (ring-)swagger 2.0 format as-is without any side-effects. Something like:\r\n\r\n```clojure\r\n; publishes the data as swagger-parameters without any side-effects / coercion.\r\n; Examples:\r\n; :swagger {:responses {200 {:schema User}\r\n;                       404 {:schema Error\r\n;                            :description \"Not Found\"} }\r\n;           :paramerers {:query {:q s/Str}\r\n;                        :body NewUser}}}\r\n(defmethod restructure-param :swagger [_ swagger acc]\r\n  (update-in acc [:parameters] deep-merge swagger))\r\n```\r\n\r\nYou could pass the (accumulated) swagger data into a inner fn via request injection and the inner fns could take care of validation with it. Wrapping the `ANY*` & `:swagger` into a macro would give a nice entry point for all of this, something like:\r\n\r\n```clojure\r\n(swagger-endpoint\r\n  {:responses {200 {:schema User}\r\n               404 {:schema Error\r\n                    :description \"Not Found\"} }\r\n   :paramerers {:query {:q s/Str}\r\n                :body NewUser}}}\r\n  my-resource)\r\n```\r\n\r\nhope this helps."}}