reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Cristian Saucedo 2021-03-04T01:46:42.022400Z

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

juhoteperi 2021-03-04T10:07:29.028400Z

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

juhoteperi 2021-03-04T10:16:54.028900Z

Doesn't seem to be documented. Impl is here: https://github.com/metosin/schema-tools/blob/master/src/schema_tools/swagger/core.cljc#L160-L164 Keys with :swagger ns from the additional data are merged to the properties swagger spec.

Matheus Moreira 2021-03-04T09:15:26.026Z

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).

dharrigan 2021-03-04T09:17:05.026900Z

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

dharrigan 2021-03-04T09:17:37.027100Z

(:require
   [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
  [data]
  (setval [DEEP-MAP-VALS nil?] NONE data))

dharrigan 2021-03-04T09:17:56.027600Z

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

dharrigan 2021-03-04T10:48:39.029500Z

@matheus.emm if you're interested, I've put together a working example here: https://github.com/dharrigan/strip-nils

Matheus Moreira 2021-03-04T10:48:55.030Z

Cool, thanks!

dharrigan 2021-03-04T10:48:56.030200Z

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