2017-12-03 15:43:40 +00:00
|
|
|
(ns example.schema
|
|
|
|
|
(:require [schema.core :as s]
|
2018-01-01 20:10:15 +00:00
|
|
|
[reitit.coercion.schema]))
|
2017-12-03 15:43:40 +00:00
|
|
|
|
|
|
|
|
(def routes
|
2018-01-01 20:10:15 +00:00
|
|
|
["/schema" {:coercion reitit.coercion.schema/coercion}
|
2018-08-27 06:12:09 +00:00
|
|
|
["/plus" {:responses {200 {:body {:total s/Int}}}
|
2017-12-03 15:43:40 +00:00
|
|
|
:get {:summary "plus with query-params"
|
|
|
|
|
:parameters {:query {:x s/Int, :y s/Int}}
|
|
|
|
|
:handler (fn [{{{:keys [x y]} :query} :parameters}]
|
|
|
|
|
{:status 200
|
|
|
|
|
:body {:total (+ x y)}})}
|
|
|
|
|
:post {:summary "plus with body-params"
|
|
|
|
|
:parameters {:body {:x s/Int, :y s/Int}}
|
|
|
|
|
:handler (fn [{{{:keys [x y]} :body} :parameters}]
|
|
|
|
|
{:status 200
|
|
|
|
|
:body {:total (+ x y)}})}}]])
|