Fork me on GitHub
Cristian Saucedo01:03:42

Hello all does anyone have any idea where I should be passing the collection-format : "csv" option in order to parse query parameters values in a comma separated list? Looking through the source code, it looks like in schema-tools.swagger.core on line 51, the default option is multi, but I can't seem to find the right spot to overide that default. The default behavior on reitit swagger is to send multiple values of the same query parameters as duplicate query parameters, i.e ?id=1&id=2 . I'd like to support the structure ?id=1,2


Hmm, in Compojure-api/Ring-swagger this was using describe/field function, but it is a bit different here.


Aha yes. schema-tools.core/schema allows attaching additional data to a schema. (st/schema [s/Str] {:swagger/collection-format "csv"})

đź‘Ź 3

Doesn't seem to be documented. Impl is here: Keys with :swagger ns from the additional data are merged to the properties swagger spec.

Matheus Moreira09:03:26

Hello! I am using muuntaja with reitit for response formatting (`format-response-middleware`) and I’d like to know if there is a way to configure the underlying object mapper to not write json properties with null value. Jackson’s object mapper supports it and I saw that jsonista uses Jackson’s OM, but I didn’t find a way to set this option (i.e. ObjectMapper.disable(SerializationFeature/WRITE_NULL_MAP_VALUES).


Jsonista doesn't support this option directly, but you can use :mapper (or :factory) options to provide custom base ObjectMapper. (json/object-mapper {:mapper (doto (ObjectMapper.) (.disable ...))})


I do something a bit different (not saying it's better, just that I approached this from a different angle). I use specter to strip out any nil's from my maps before I send them out


   [com.rpl.specter :refer [declarepath providepath if-path compact setval MAP-VALS NONE STAY]]))

(set! *warn-on-reflection* true)

(declare DEEP-MAP-VALS)
(declarepath DEEP-MAP-VALS)
(providepath DEEP-MAP-VALS (if-path map? [(compact MAP-VALS) DEEP-MAP-VALS] STAY))

(defn clean
  (setval [DEEP-MAP-VALS nil?] NONE data))


So I would call (clean my-data-structure) just before passing it back out


@matheus.emm if you're interested, I've put together a working example here:


This provides serialisation features to Jackson, to strip out the nils, with examples