mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 00:41:12 +00:00
doc: update examples/ring-spec-swagger to include OpenAPI 3
This commit is contained in:
parent
28e9cc01e5
commit
f14808b8a3
3 changed files with 17 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
# reitit-ring, clojure.spec, swagger
|
# reitit-ring, clojure.spec, swagger, openapi 3
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
@ -7,6 +7,10 @@
|
||||||
(start)
|
(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/):
|
To test the endpoints using [httpie](https://httpie.org/):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
(ns example.server
|
(ns example.server
|
||||||
(:require [reitit.ring :as ring]
|
(:require [reitit.ring :as ring]
|
||||||
[reitit.coercion.spec]
|
[reitit.coercion.spec]
|
||||||
|
[reitit.openapi :as openapi]
|
||||||
[reitit.swagger :as swagger]
|
[reitit.swagger :as swagger]
|
||||||
[reitit.swagger-ui :as swagger-ui]
|
[reitit.swagger-ui :as swagger-ui]
|
||||||
[reitit.ring.coercion :as coercion]
|
[reitit.ring.coercion :as coercion]
|
||||||
|
|
@ -44,9 +45,15 @@
|
||||||
{:get {:no-doc true
|
{:get {:no-doc true
|
||||||
:swagger {:info {:title "my-api"}}
|
:swagger {:info {:title "my-api"}}
|
||||||
:handler (swagger/create-swagger-handler)}}]
|
: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"
|
["/files"
|
||||||
{:swagger {:tags ["files"]}}
|
{:tags ["files"]}
|
||||||
|
|
||||||
["/upload"
|
["/upload"
|
||||||
{:post {:summary "upload a file"
|
{:post {:summary "upload a file"
|
||||||
|
|
@ -67,7 +74,7 @@
|
||||||
(io/resource "reitit.png"))})}}]]
|
(io/resource "reitit.png"))})}}]]
|
||||||
|
|
||||||
["/math"
|
["/math"
|
||||||
{:swagger {:tags ["math"]}}
|
{:tags ["math"]}
|
||||||
|
|
||||||
["/plus"
|
["/plus"
|
||||||
{:get {:summary "plus with spec query parameters"
|
{:get {:summary "plus with spec query parameters"
|
||||||
|
|
@ -111,6 +118,9 @@
|
||||||
(swagger-ui/create-swagger-ui-handler
|
(swagger-ui/create-swagger-ui-handler
|
||||||
{:path "/"
|
{:path "/"
|
||||||
:config {:validatorUrl nil
|
:config {:validatorUrl nil
|
||||||
|
:urls [{:name "swagger" :url "swagger.json"}
|
||||||
|
{:name "openapi" :url "openapi.json"}]
|
||||||
|
:urls.primaryName "openapi"
|
||||||
:operationsSorter "alpha"}})
|
:operationsSorter "alpha"}})
|
||||||
(ring/create-default-handler))))
|
(ring/create-default-handler))))
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 94 KiB |
Loading…
Reference in a new issue