Should uniqueItems reject duplicates?
kubukoz opened this issue · comments
According to the spec:
6.7. uniqueItems trait
Summary
Requires the items in a list to be unique based on Value equality.
Our implementation relies on scala's default Set behavior, which is to remove duplicates. The spec seems to be more strict than that.
Here's more precedent for rejecting lists that have duplicate entries:
- the node validator, used for list traits
- restJson1 protocol tests
I think you are correct. uniqueItems
should be treated as a validation constraint as opposed to a meta-hint dictating the generated type.
thoughts/questions off the top of my head:
- we could turn
uniqueItems
into a usual.validated
/.refine
call on Schema. If it'srefine
, it could turn the collection type into aSet
.- should it actually change the collection type?
- if not, do we give users the ability to do that (keep Set in the codegen), e.g.
@smithy4s.meta#scalaSet
?
- if not, do we give users the ability to do that (keep Set in the codegen), e.g.
- does this remove the need for a
SetTag
to exist?
- should it actually change the collection type?