ring-swagger

ring-swagger & compojure-api
ammazza 2018-01-11T03:20:07.000134Z

Hello! I'm at my first attempt at using swagger and compojure-api. Is there a (simple) way to get swagger UI to present different documents for different contexts?

ikitommi 2018-01-11T08:36:30.000128Z

It depends. You can have multiple apis next to each other with different route trees - and those route trees can share same routes. Also, you can mount multiple swagger-spec endpoints manually and mofidy the resulting specs via a response middleware. But thats not trivial I guess.

plamen 2018-01-11T14:58:58.000119Z

Hello, is there a way to define a context/resource in compojure-api/swagger with clojure.spec as coercion for URIs of the form /balance-sheet/aggregation1/aggregation2.../aggregationN/value, where the depth N of aggregations is not known in advance?

plamen 2018-01-11T15:02:09.000508Z

I know how to do it with the fixed parts of the URI (balance-sheet and value), but no idea if it even possible in the context above without resorting to a custom path definition like /balance-sheet/aggregation1aggregation2aggregationN/value. The problem is that in that scheme, the aggregation path can be parsed independent of compojure-api/spec/swagger, but it is a hack in every possible dimension.

ikitommi 2018-01-11T19:14:51.000468Z

@plamen swagger if for static documentation, so I don’t think it can present such for documentation. I think you can do such a thing with compojure thou. There is an example of dynamic routing in https://github.com/metosin/compojure-api/tree/master/examples/reusable-resources. Should be streightforward to port it to spec.

ikitommi 2018-01-11T19:15:04.000099Z

hope that helps.

ammazza 2018-01-11T23:11:47.000206Z

I see... well, it was mostly about making the documentation page tidier. In the meantime I learned about :tags in the contexts, so now at least I have a title for each context and I can hide/show its functions independently.