This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-26
Channels
- # admin-announcements (1)
- # beginners (1)
- # boot (252)
- # braveandtrue (1)
- # cider (17)
- # clojure (58)
- # clojure-chicago (3)
- # clojure-russia (125)
- # clojure-uk (2)
- # clojurescript (38)
- # hoplon (3)
- # lein-figwheel (11)
- # leiningen (1)
- # mount (2)
- # off-topic (3)
- # om (9)
- # onyx (39)
- # parinfer (24)
- # proton (7)
- # protorepl (7)
- # quil (4)
- # re-frame (16)
- # reagent (5)
- # ring-swagger (18)
- # yada (1)
@jablub: yes there is, multiple ways to do that - could you tell more about your use case? but anyway, these alla work:
1) per endpoint, document the endpoint using :swagger
meda-data (https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L82-L90)
2) disable the input&output coercion, either per route (via :coercion
) or per whole api (via options)
3) 1.0.2-SNAPSHOT
has the resource
abstraction, currently eager, but could make it optionally just to produce docs => could be used to easily document things like Liberator resources
I have an compojure-api which takes a message and puts it on a queue and returns a 200 - even for invalid messages. The message gets validated with schema on the consumer side of the queue, but the external group also wants swagger docs available.
I would like to keep the schemas as the single source of documentation so options 2 and 3 seem good. I haven't looked into it yet but 2 seems simplest. If you feel option 3 would be a better call I will go for that. Our project is still at the stage where working off current development branches is still allowed. I will try both.
I think option 1 makes most sense in that usecase
I've got an issue with compojure and schema where it works from swagger but not from any other source (I'm calling http post), the error isn't very useful - {"errors":"(not (map? nil))"}
ive copied my request body into the endpoint test at /swagger-ui and the request goes through fine from there
@ysealy08 I guess this describes your case too? https://github.com/metosin/compojure-api/issues/226
does @juhoteperi have a idea how to Fix that in an elegantti way?
my issue is a bit different in that the only place the request works is from the swagger endpoint, when I try to make the call from the frontend it fails with that error
if the client doesn't send any body, e.g. invalid json headers, which causes the body not to be parsed (in ring-middleware-format), it is send as nil
. Body is expected to be a Map, so thus the schema error.
Merging an empty map with the parsed body would give a lot of missing-required-key errors. Adding logging to request-coercion might help to find the cause.
There is a guide for the exceptions here: https://github.com/metosin/compojure-api/wiki/Exception-handling
@ysealy08: content-type is invalid. application-json
vs. application/json