Fork me on GitHub
#ring-swagger
<
2015-08-18
>
settinghead01:08:03

i’m trying to use compojure.api.sweet and schema.core to define some swagger api endpoints. is there a way to make a query-param optional? i wasn’t able to find an example for it

settinghead01:08:18

(context* “/items" []
              :tags ["search"]
             (GET* "/" []
                   :return      [Item]
                   :query-params [(s/optional-key s_text) :-  (s/maybe String)
                                  s_city :- Long
                                  s_sort_reverse :- (s/maybe Boolean)]
                   :summary     “item[query, city-id]"
                   (ok (search-items s_city s_text nil nil nil))))

settinghead01:08:35

apparently i was doing it wrong with (s/optional-key s_text) . but what is the correct syntax?

juhoteperi06:08:54

:query-params uses plumbing syntax: [{s_text :- String "default value"}]

settinghead14:08:29

awesome it worked! thanks