mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
doc: use malli vars in examples/openapi
This commit is contained in:
parent
57fc00a45e
commit
3cb387747b
1 changed files with 37 additions and 2 deletions
|
|
@ -12,8 +12,28 @@
|
|||
[reitit.ring.middleware.multipart :as multipart]
|
||||
[reitit.ring.middleware.parameters :as parameters]
|
||||
[ring.adapter.jetty :as jetty]
|
||||
[malli.core :as malli]
|
||||
[muuntaja.core :as m]))
|
||||
|
||||
(def Transaction
|
||||
[:map
|
||||
[:amount :double]
|
||||
[:from :string]])
|
||||
|
||||
(def AccountId
|
||||
[:map
|
||||
[:bank :string]
|
||||
[:id :string]])
|
||||
|
||||
(def Account
|
||||
[:map
|
||||
[:bank :string]
|
||||
[:id :string]
|
||||
[:balance :double]
|
||||
[:transactions [:vector #'Transaction]]])
|
||||
|
||||
|
||||
|
||||
(def app
|
||||
(ring/ring-handler
|
||||
(ring/router
|
||||
|
|
@ -89,8 +109,23 @@
|
|||
[:email {:json-schema/example "heidi@alps.ch"}
|
||||
string?]]]}}}}
|
||||
:handler (fn [_request]
|
||||
[{:name "Heidi"
|
||||
:email "heidi@alps.ch"}])}}]
|
||||
{:status 200
|
||||
:body [{:name "Heidi"
|
||||
:email "heidi@alps.ch"}]})}}]
|
||||
|
||||
["/account"
|
||||
{:get {:summary "Fetch an account | Recursive schemas using malli registry"
|
||||
:parameters {:query #'AccountId}
|
||||
:responses {200 {:content {:default {:schema #'Account}}}}
|
||||
:handler (fn [_request]
|
||||
{:status 200
|
||||
:body {:bank "MiniBank"
|
||||
:id "0001"
|
||||
:balance 13.5
|
||||
:transactions [{:from "0002"
|
||||
:amount 20.0}
|
||||
{:from "0003"
|
||||
:amount -6.5}]}})}}]
|
||||
|
||||
["/secure"
|
||||
{:tags #{"secure"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue