disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

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's refine, it could turn the collection type into a Set.
    • 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?
    • does this remove the need for a SetTag to exist?