ring-swagger

ring-swagger & compojure-api
niels 2018-11-14T15:24:50.054700Z

hi there

niels 2018-11-14T15:25:04.055100Z

I'm having some trouble getting the :definitions map to appear in swagger.json

niels 2018-11-14T15:27:06.055400Z

niels 2018-11-14T15:27:41.056300Z

a little context: checking out 2.0 compojure api with spec coercion

niels 2018-11-14T15:28:31.057100Z

for some reason my swagger.json keeps returning empty map definitions: {}

niels 2018-11-14T15:33:28.057500Z

maybe it's because I'm not $ref'ing it anywhere

ikitommi 2018-11-14T16:09:36.058500Z

@nmdrenard the definitions are extracted automatically from endpoints. I’m not sure it can be overridden via the :swagger options. Would you like to write those manually?

niels 2018-11-14T16:11:08.059300Z

What I'm trying to get is the "Models" tab, as can be seen here: https://petstore.swagger.io/

niels 2018-11-14T16:11:10.059600Z

scroll to the bottom

niels 2018-11-14T16:13:27.061700Z

I've got a couple endpoints, validating with spec, both input and output, so that works (really nicely!) But I'd like to have that "Models" thing too. Maybe this is a swagger-ui 3.0 thing?

ikitommi 2018-11-14T16:16:42.062700Z

I think spec-tools doesn’t at the moment support spec references, all models are inlined in the endpoints. Also, this is only visible with the swagger-ui 3.0 (that’s easy to update).

ikitommi 2018-11-14T16:17:15.063200Z

Schema/Ring-swagger supports that, just not spec. There is an PR for it, but looks stalled.

ikitommi 2018-11-14T16:17:57.063500Z

here’s the sample spec-tools generates: https://github.com/metosin/spec-tools#full-example

ikitommi 2018-11-14T16:19:45.065300Z

should be streightforward to collect all the specs with title, ensure they don’t clash, change them to references and put the references under definitions. I personally don’t have time for that, but PR most welcome.

niels 2018-11-14T16:22:27.066400Z

gotcha

niels 2018-11-14T16:22:30.066600Z

link to PR?

niels 2018-11-14T16:22:55.067100Z

It's not critical at all, will just instruct users to do an extra click to the endpoints

niels 2018-11-14T16:23:19.067600Z

and thanks for helping research!

ikitommi 2018-11-14T16:31:54.067700Z

@nmdrenard https://github.com/metosin/spec-tools/pull/110

1👍
ikitommi 2018-11-14T16:34:59.068400Z

noprob