Skip to content

Commit

Permalink
doc: use malli vars in examples/openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
opqdonut committed Apr 22, 2024
1 parent 57fc00a commit 3cb3877
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions examples/openapi/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,8 +109,23 @@
[:email {:json-schema/example "[email protected]"}
string?]]]}}}}
:handler (fn [_request]
[{:name "Heidi"
:email "[email protected]"}])}}]
{:status 200
:body [{:name "Heidi"
:email "[email protected]"}]})}}]

["/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"}
Expand Down

0 comments on commit 3cb3877

Please sign in to comment.