Fork me on GitHub
#ring-swagger
<
2017-06-02
>
ikitommi05:06:40

good morning @michaelblume. Didn’t know that 1-arity merge is a code smell. The endpoint macros generate the code and the merge can end up with 1+ arguments. But wanted to understand this and did a optimised merge-vector handling the 1-arity differently. FIxes the warning (thanks for the sample repo!) and is as a bonus 10x faster for the default case. See https://github.com/metosin/compojure-api/pull/311

nicoschneider11:06:35

hello everybody, i’m just getting started with compojure/swagger. I have a chestnut application (the newest release) setup, and my initial attempts all work fine. i’m having trouble understanding the swagger.json file – is this a static file resource somewhere or can i programatically generate it? how do i integrate that with my app, simply register a swagger.json route and return the json content via ring-swagger? thank you

ikitommi18:06:18

@nicoschneider hi. the swagger-things are mostly auto generated if you use compojure-api. I think the default chestnut uses plain compojure, so you should change that.

ikitommi18:06:49

I think the best way to see what compojure-api does is to run it’s own template: lein new compojure-api kikka

ikitommi18:06:18

that sets up a really minimal web server, which has two endpoint with schema-validation & swagger-docs.

ikitommi18:06:28

the readme describes how to start etc.

ikitommi18:06:58

but the idea is that you write your compojure(-api) routes just like with compojure, wrap them in api and add some swagger-options to it. api reads the reverse-routing tree + the schemas attached to routes and creates valid swagger.json out of those. There are api-options to mount a endpoint for serving both the swagger.json and the swagger-ui.

ikitommi18:06:20

once you have a running compojure-api sample, it should (hopefully) be streightforward to take those changes to your template project. basically just remove any json-format middlewares (compojure-api ships with it’s own), wrap the apis into api and change imports from compojure.core to compojure.api.sweet.

ikitommi18:06:26

hope this helps to get started