mirror of
https://github.com/metosin/reitit.git
synced 2025-12-16 16:01:11 +00:00
doc: return random content-type from openapi example /pizza
This commit is contained in:
parent
7fb9c27e46
commit
39c5ae86a4
1 changed files with 17 additions and 6 deletions
|
|
@ -52,23 +52,34 @@
|
||||||
{:get {:summary "Fetch a pizza | Multiple content-types, multiple examples"
|
{:get {:summary "Fetch a pizza | Multiple content-types, multiple examples"
|
||||||
:responses {200 {:description "Fetch a pizza as json or EDN"
|
:responses {200 {:description "Fetch a pizza as json or EDN"
|
||||||
:content {"application/json" {:schema [:map
|
:content {"application/json" {:schema [:map
|
||||||
|
[:format [:enum :json]]
|
||||||
[:color :keyword]
|
[:color :keyword]
|
||||||
[:pineapple :boolean]]
|
[:pineapple :boolean]]
|
||||||
:examples {:white {:description "White pizza with pineapple"
|
:examples {:white {:description "White pizza with pineapple"
|
||||||
:value {:color :white
|
:value {:format :json
|
||||||
|
:color :white
|
||||||
:pineapple true}}
|
:pineapple true}}
|
||||||
:red {:description "Red pizza"
|
:red {:description "Red pizza"
|
||||||
:value {:color :red
|
:value {:format :json
|
||||||
|
:color :red
|
||||||
:pineapple false}}}}
|
:pineapple false}}}}
|
||||||
"application/edn" {:schema [:map
|
"application/edn" {:schema [:map
|
||||||
|
[:format [:enum :edn]]
|
||||||
[:color :keyword]
|
[:color :keyword]
|
||||||
[:pineapple :boolean]]
|
[:pineapple :boolean]]
|
||||||
:examples {:red {:description "Red pizza with pineapple"
|
:examples {:red {:description "Red pizza with pineapple"
|
||||||
:value (pr-str {:color :red :pineapple true})}}}}}}
|
:value (pr-str {:format :edn :color :red :pineapple true})}}}}}}
|
||||||
:handler (fn [_request]
|
:handler (fn [_request]
|
||||||
{:status 200
|
(rand-nth [{:status 200
|
||||||
:body {:color :red
|
:muuntaja/content-type "application/json"
|
||||||
:pineapple true}})}
|
:body {:format :json
|
||||||
|
:color :red
|
||||||
|
:pineapple true}}
|
||||||
|
{:status 200
|
||||||
|
:muuntaja/content-type "application/edn"
|
||||||
|
:body {:format :edn
|
||||||
|
:color :red
|
||||||
|
:pineapple true}}]))}
|
||||||
:post {:summary "Create a pizza | Multiple content-types, multiple examples | Default response schema"
|
:post {:summary "Create a pizza | Multiple content-types, multiple examples | Default response schema"
|
||||||
:request {:description "Create a pizza using json or EDN"
|
:request {:description "Create a pizza using json or EDN"
|
||||||
:content {"application/json" {:schema [:map
|
:content {"application/json" {:schema [:map
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue