mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11: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.multipart :as multipart]
|
||||||
[reitit.ring.middleware.parameters :as parameters]
|
[reitit.ring.middleware.parameters :as parameters]
|
||||||
[ring.adapter.jetty :as jetty]
|
[ring.adapter.jetty :as jetty]
|
||||||
|
[malli.core :as malli]
|
||||||
[muuntaja.core :as m]))
|
[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
|
(def app
|
||||||
(ring/ring-handler
|
(ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
|
|
@ -89,8 +109,23 @@
|
||||||
[:email {:json-schema/example "heidi@alps.ch"}
|
[:email {:json-schema/example "heidi@alps.ch"}
|
||||||
string?]]]}}}}
|
string?]]]}}}}
|
||||||
:handler (fn [_request]
|
:handler (fn [_request]
|
||||||
[{:name "Heidi"
|
{:status 200
|
||||||
:email "heidi@alps.ch"}])}}]
|
: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"
|
["/secure"
|
||||||
{:tags #{"secure"}
|
{:tags #{"secure"}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue