reitit icon indicating copy to clipboard operation
reitit copied to clipboard

Unclear where swagger tags should be placed

Open Deraen opened this issue 4 years ago • 4 comments

Swagger feature docstring (and spec?) places tags on route-data root:

https://github.com/metosin/reitit/blob/master/modules/reitit-swagger/src/reitit/swagger.cljc#L55

Examples place tags key under swagger:

https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj#L30

Both seem to generate proper swagger.json, but first one fails spec validation. Why? Spec seems to list tags as top-level key.

Deraen avatar Mar 11 '20 16:03 Deraen

You need to mount swagger-feature as a middleware|interceptor, which adds the valid keys to the route data for the routes swagger-feature effects

ikitommi avatar Mar 11 '20 16:03 ikitommi

e.g. all specs from mw/int :spec key accumulate to the route spec. Would be great to see the accumulated spec per endpoint.

ikitommi avatar Mar 11 '20 17:03 ikitommi

I think the right solution is to remove the top-level :tags completely and use path [:swagger :tags] instead.

ikitommi avatar Mar 11 '20 17:03 ikitommi

oh, it a breaking. but the :tags has never been part of the route spec, so this is still a bug fix. need to push a minor out with this.

On Thu, Jun 25, 2020 at 12:36 PM Tommi Jalkanen [email protected] wrote:

I know it would be a breaking change but what about this line: https://github.com/metosin/reitit/blob/9ca88d7165c97ec1c5bb87dd5a217bc58ad1de50/modules/reitit-swagger/src/reitit/swagger.cljc#L96

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/metosin/reitit/issues/375#issuecomment-649425705, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEKR3DY5AUB2OBBWQFEGEDRYMLDJANCNFSM4LF2IESQ .

ikitommi avatar Jun 26 '20 07:06 ikitommi