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 for Swagger/OpenAPI #19
Labels
Projects
Comments
This was referenced Dec 21, 2017
Merged
Works with spec (clj + cljs), Schema is wip. (require '[reitit.ring :as ring])
(require '[reitit.swagger :as swagger])
(require '[reitit.ring.coercion :as rrc])
(require '[reitit.coercion.spec :as spec])
(require '[reitit.coercion.schema :as schema])
(require '[schema.core :refer [Int]])
(require '[muuntaja.middleware])
(ring/ring-handler
(ring/router
["/api"
{:swagger {:id ::math}}
["/swagger.json"
{:get {:no-doc true
:swagger {:info {:title "my-api"}}
:handler swagger/swagger-spec-handler}}]
["/spec" {:coercion spec/coercion}
["/plus"
{:get {:summary "plus"
:parameters {:query {:x int?, :y int?}}
:responses {200 {:body {:total int?}}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200, :body {:total (+ x y)}})}}]]
["/schema" {:coercion schema/coercion}
["/plus"
{:get {:summary "plus"
:parameters {:query {:x Int, :y Int}}
:responses {200 {:body {:total Int}}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200, :body {:total (+ x y)}})}}]]]
{:data {:middleware [muuntaja.middleware/wrap-format
swagger/swagger-feature
rrc/coerce-exceptions-middleware
rrc/coerce-request-middleware
rrc/coerce-response-middleware]}})) |
Schema is done too, all SNAPSHOTS. |
Ultimate Swagger guide at https://metosin.github.io/reitit/ring/swagger.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal:
metosin/reitit-swagger
(andmetosin/reitit-openapi
) module:responses
and:parameters
data is read from coercion:no-docs
(disable docs),:swagger
(any swagger-data)swagger-middleware
that doesn't participate in request processing but provides specs for the new keys for route data validationswagger-spec-handler
that produces the swagger-spec[:swagger :id]
defines the api(docs). All routes with the same id are part of the apidcsDraft with data-specs:
The text was updated successfully, but these errors were encountered: