disneystreaming / smithy4s

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Constraints on collections members are not enforced

ghostbuster91 opened this issue · comments

Given the following smithy model:

@simpleRestJson
service WeatherService {
    operations: [GetWeather]
}

@http(method: "POST", uri: "/weather")
@readonly
operation GetWeather {
    input := {
        @required
        map: StringList
    }
    output := {
        @required
        weather: String
    }
}

list StringList {
    @length(min:2)
    member: String
}

smithy4s does not generate constraint traits for StringList class:

object StringList extends Newtype[List[String]] {
  val id: ShapeId = ShapeId("hello", "StringList")
  val hints: Hints = Hints.empty
  val underlyingSchema: Schema[List[String]] = list(string.addMemberHints()).withId(id).addHints(hints)
  implicit val schema: Schema[StringList] = bijection(underlyingSchema, asBijection)
}

according to smithy documentation length trait can be applied to:

Any list, map, string, or blob; or a member that targets one of these shape

full reproduction: https://github.com/ghostbuster91/demos/tree/list-validation
smithy4s version: 0.18.15

@miguel-vila is looking into this.

Closed in #1498.