smithy.api.Enum.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Hints
import smithy4s.Newtype
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.list
import smithy4s.schema.Schema.recursive
/** Constrains the acceptable values of a string to a fixed set
* of constant values.
* @param member
* An enum definition for the enum trait.
*/
@deprecated(message = "The enum trait is replaced by the enum shape in Smithy 2.0", since = "2.0")
object Enum extends Newtype[List[EnumDefinition]] {
val id: ShapeId = ShapeId("smithy.api", "enum")
val hints: Hints = Hints(
smithy.api.Documentation("Constrains the acceptable values of a string to a fixed set\nof constant values."),
smithy.api.Trait(selector = Some("string :not(enum)"), structurallyExclusive = None, conflicts = None, breakingChanges = Some(List(smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.PRESENCE.widen, severity = smithy.api.Severity.ERROR.widen, path = None, message = None)))),
smithy.api.Deprecated(message = Some("The enum trait is replaced by the enum shape in Smithy 2.0"), since = Some("2.0")),
).lazily
val underlyingSchema: Schema[List[EnumDefinition]] = list(EnumDefinition.schema).withId(id).addHints(hints).validated(smithy.api.Length(min = Some(1L), max = None))
implicit val schema: Schema[Enum] = recursive(bijection(underlyingSchema, asBijection))
}