Optional query parameters (with default value) with compojure-api
For your first issue, this is working as designed. When you had your boolean query param required, Swagger rendered the UI which forces you to choose a value (either true
or false
, it just happens that it displays true on the first place).
When you changed the boolean query param to be optional, then the first empty value means "don't send this query param at all" and when you don't change it to true
or false
it won't append this query param to the request.
Regarding your second issue with integer query param: by default schema's json-coercion-matcher
specifies String->Long
coercion but not String->Integer
so there is no support for Integer
out of the box. You can specify your own coercer globally for your API or per route by using :coercion
option (there is an example in compojure-api test). You could provide your own coercer which could extend the existing json-coercion-matcher
with String->Integer
case.