Fork me on GitHub
#ring-swagger
<
2016-03-26
>
ikitommi08:03:50

@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

jablub18:03:27

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.

jablub18:03:56

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.

juhoteperi18:03:02

I think option 1 makes most sense in that usecase

ysealy0818:03:28

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))"}

ysealy0818:03:01

ive copied my request body into the endpoint test at /swagger-ui and the request goes through fine from there

ikitommi18:03:41

does @juhoteperi have a idea how to Fix that in an elegantti way?

ysealy0818:03:32

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

ysealy0818:03:46

I've inspected the headers, etc and those are fine

ikitommi18:03:10

I guess we should merge empty map when *-params is used.

ikitommi18:03:51

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.

ikitommi19:03:06

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.

ysealy0819:03:05

yes that would help, I've been trying to inject some logging

juhoteperi19:03:55

@ysealy08: content-type is invalid. application-json vs. application/json

ysealy0819:03:11

😕 hmm good catch, I'm setting application/json on the frontend end code for sure, I'll investigate why this is happening