ring-swagger

ring-swagger & compojure-api
2017-10-25T15:48:59.000185Z

does anyone know of any documentation/samples for customizing the examples provided with the swagger ui

2017-10-25T16:33:56.000289Z

nvm i managed to find it

2017-10-25T16:34:13.000338Z

you can use ‘describe’ to add swagger metadata to a schema

2017-10-25T16:58:18.000611Z

@nickmbailey where did you find that? just curious

2017-10-25T16:59:18.000095Z

just browsing around in the examples directory

2017-10-25T16:59:46.000168Z

specifically i noticed using ‘describe’ here: https://github.com/metosin/compojure-api/blob/master/examples/thingie/src/examples/thingie.clj#L58

2017-10-25T16:59:58.000104Z

so i looked that up and saw it merged swagger metadata with a schema object

2017-10-25T17:00:28.000501Z

so tried it out by doing (describe MySchema “blah” :example “json_string”)

2017-10-25T17:00:35.000204Z

and voila

👍 1
😁 1
2017-10-25T17:03:42.000174Z

what’s actually really awesome is that describe just adds clojure metadata so you can just put it in your defschema

ikitommi 2017-10-25T17:41:52.000159Z

Related: https://github.com/metosin/schema-tools/issues/32

ikitommi 2017-10-25T17:43:53.000158Z

Spec sample:

(jsc/transform
  (st/spec
    {:spec integer?
     :name "integer"
     :description "it's an int"
     :json-schema/default 42}))
; {:type "integer"
;  :title "integer"
;  :description "it's an int"
;  :default 42}