Skip to content

Conversation

antonmos
Copy link
Contributor

@antonmos antonmos commented Feb 11, 2020

… coerced

in my situation, i am using a spec like this to transform the parameter:

(def get-events-spec
  (st/spec
    {:spec (s/coll-of string?)
     :description "comma separated list of user-ids"
     :json-schema/type {:type "string"}
     :json-schema/example "1,2,3"
     :decode/string #(cs/split %2 #",")
     :encode/string #(cs/join %2 ",")}))

referenced like this

(GET "/events" []
      :coercion :spec
      :query-params [user-ids :- get-events-spec,
                                  max-age :- ::corespec/max-age ]
...
)

When invoked with GET /events?user-ids=1 (i.e. with missing max-age param), I get a class cast exception thrown from cs/split.
This happens because the old code was calling conform on result of st/coerce, which means that the string has already been coerced into a vector of strings.

@antonmos antonmos requested review from ikitommi and Deraen February 11, 2020 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant