Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support swagger #2

Open
3 tasks
kkharji opened this issue Dec 30, 2021 · 1 comment
Open
3 tasks

Support swagger #2

kkharji opened this issue Dec 30, 2021 · 1 comment
Labels
prod-mode Releates to prod mode submodule Releates to a submodule

Comments

@kkharji
Copy link
Owner

kkharji commented Dec 30, 2021

  • Create a key for enabling swagger duct.module.reitit/swagger.
  • When key exists, inject swagger in routes using a configurable path option and configure ring-handler accordingly.
  • Support all the swagger options available in ring handler and routes
@kkharji
Copy link
Owner Author

kkharji commented Dec 30, 2021

Reitit-Swagger Overview

Documentation is extracted from route definitions, coercion :parameters and :responses and from a set of new documentation keys.

To enable swagger-documentation for a ring-router:

  1. annotate your routes with swagger-data
  2. mount a swagger-handler to serve the swagger-spec
  3. optionally mount a swagger-ui to visualize the swagger-spec

Route Keys considered in swagger:

  • :swagger map of any swagger-data. Can have :id (keyword or sequence of keywords) to identify the api
  • :no-doc optional boolean to exclude endpoint from api docs
  • :tags optional set of string or keyword tags for an endpoint api docs
  • :summary optional short string summary of an endpoint
  • :description optional long description of an endpoint. Supports http://spec.commonmark.org/
  • :parameters optional input parameters for a route, in a format defined by the coercion
  • :responses optional descriptions of responses, in a format defined by coercion

swagger spec

To serve the actual Swagger Specification, there is reitit.swagger/create-swagger-handler. It takes no arguments and returns a ring-handler which collects at request-time data from all routes for the same swagger api and returns a formatted Swagger specification as Clojure data, to be encoded by a response formatter.

@kkharji kkharji added prod-mode Releates to prod mode submodule Releates to a submodule labels Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prod-mode Releates to prod mode submodule Releates to a submodule
Projects
None yet
Development

No branches or pull requests

1 participant