Fork me on GitHub
#ring-swagger
<
2016-04-12
>
virmundi12:04:54

hello. I’m trying to convert a simple compojure api to compojure-api. I’m unable to get swagger to turn on.

virmundi12:04:13

What middleware do I need to use for that?

virmundi15:04:01

When I post using Postman for Chrome, I get "errors": "(not (map? nil))"

virmundi15:04:37

I’ve monitored the traffic the POST is getting a json body

virmundi15:04:54

This is my first use of compojure-api/swagger. What am I doing wrong?

juhoteperi15:04:08

Try removing :return nil

virmundi15:04:08

That did not work.

virmundi15:04:23

That’s how I setup the middleware

juhoteperi15:04:05

@virmundi: api already wraps the routes in api-middleware so you have dupliate middlewares currently

virmundi15:04:50

@daraen: thanks. I removed that. Still getting the error

virmundi15:04:05

the GET in the example works. This means my auth token is processed properly and the path param is getting fixed up.

virmundi15:04:36

it seems to be the POST.

juhoteperi15:04:15

Try posting to /accounts/

virmundi15:04:56

That gets a 404

virmundi15:04:10

Schema for the input is a compound schema. By that I mean that I’m referencing the NewProfile schema within the NewAccount schema. Is that possible?

ikitommi16:04:43

that should be ok.

ikitommi16:04:26

in the example, you have only the api-middleware. You should wrap apis into api

ikitommi16:04:57

You can say (api routes) to do that.

virmundi16:04:40

In the first example (there are two), I have (api..) wrap the post. Do I have to wrap it externally too?

ikitommi16:04:41

api applies the api-middleware & configures up the Swagger artifacts.

ikitommi16:04:52

do you get 400 or 500 as response code?

ikitommi16:04:05

500 indicates a response coercion error

virmundi16:04:04

400 { "errors": "(not (map? nil))" }

virmundi16:04:46

I think I’ve got something setup wrong. I looked at the other route for the GET. I noticed that I used compojure destructuring on the path, not compojure-api. When I switch, the GET fails now with missing key

virmundi16:04:55

never mind about the GET issue. I forgot the :0

ikitommi16:04:42

nil-body indicates that a) the is no body (e.g. Bad content-type) b) someone has slurped the body and hasn't parsed the json body into body params

virmundi16:04:31

Is there a tutorial for using this with buddy auth? That’s the only other middleware I’m using.

virmundi16:04:12

woot. got it. Context: this was a compojure app getting converted to compojure-api for all it’s goodness. Issue: I didn’t update the middleware level to use api over routes

virmundi16:04:08

That’s probably what @ikitommi meant. I just didn’t understand. Thanks

ikitommi17:04:27

great! Pre-integrating Buddy to c-api & Swagger is in the todo-list. PRs welcome too.

virmundi17:04:26

Maybe one day I’ll do a PR. I’m just starting out.