-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s/enum
doesn't preserve order
#453
Comments
Open to a PR, thanks for the report! Is there a x-platform equivalent of LinkedHashSet? If not, we could store the ordered list and the set separately potentially? |
I think attaching the original (macros/defrecord-schema EnumSchema [vs]
Schema
(explain [this] (or (::explain this)
;; backwards compat for users of ->EnumSchema
(cons 'enum vs))))
(clojure.core/defn enum
"A value that must be = to some element of vs."
[& vs]
(assoc (EnumSchema. (set vs))
::explain (cons 'enum vs))) EDIT: hmm, well EnumSchema is a record so an |
Well, we could just treat the ordering as a hint that we can discard if the actual entries differ. |
s/enum
doesn't preserve the order of the elements provided.The order is lost at https://github.com/plumatic/schema/blob/master/src/cljc/schema/core.cljc#L295 when
set
is called.This screws up ordering, for example, in swagger.
Replacing
set
withLinkedHashSet.
would preserve orderThe text was updated successfully, but these errors were encountered: