doc: update examples/ring-spec-swagger to include OpenAPI 3

This commit is contained in:
Joel Kaasinen 2023-05-03 17:11:07 +03:00
parent 28e9cc01e5
commit f14808b8a3
3 changed files with 17 additions and 3 deletions

View file

@ -1,4 +1,4 @@
# reitit-ring, clojure.spec, swagger
# reitit-ring, clojure.spec, swagger, openapi 3
## Usage
@ -7,6 +7,10 @@
(start)
```
- Swagger spec served at <http://localhost:3000/swagger.json>
- Openapi spec served at <http://localhost:3000/openapi.json>
- Swagger UI served at <http://localhost:3000/>
To test the endpoints using [httpie](https://httpie.org/):
```bash

View file

@ -1,6 +1,7 @@
(ns example.server
(:require [reitit.ring :as ring]
[reitit.coercion.spec]
[reitit.openapi :as openapi]
[reitit.swagger :as swagger]
[reitit.swagger-ui :as swagger-ui]
[reitit.ring.coercion :as coercion]
@ -44,9 +45,15 @@
{:get {:no-doc true
:swagger {:info {:title "my-api"}}
:handler (swagger/create-swagger-handler)}}]
["/openapi.json"
{:get {:no-doc true
:openapi {:info {:title "my-api"
:description "openapi3-docs with reitit-http"
:version "0.0.1"}}
:handler (openapi/create-openapi-handler)}}]
["/files"
{:swagger {:tags ["files"]}}
{:tags ["files"]}
["/upload"
{:post {:summary "upload a file"
@ -67,7 +74,7 @@
(io/resource "reitit.png"))})}}]]
["/math"
{:swagger {:tags ["math"]}}
{:tags ["math"]}
["/plus"
{:get {:summary "plus with spec query parameters"
@ -111,6 +118,9 @@
(swagger-ui/create-swagger-ui-handler
{:path "/"
:config {:validatorUrl nil
:urls [{:name "swagger" :url "swagger.json"}
{:name "openapi" :url "openapi.json"}]
:urls.primaryName "openapi"
:operationsSorter "alpha"}})
(ring/create-default-handler))))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 94 KiB