All Downloads are FREE. Search and download functionalities are using the official Maven repository.

smithy.api.Default.scala Maven / Gradle / Ivy

There is a newer version: 0.19.0-41-91762fb
Show newest version
package smithy.api

import smithy4s.Document
import smithy4s.Hints
import smithy4s.Newtype
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.document
import smithy4s.schema.Schema.recursive

/** Provides a structure member with a default value. When added to root
  * level shapes, requires that every targeting structure member defines the
  * same default value on the member or sets a default of null.
  * 
  * This trait can currently only be used in Smithy 2.0 models.
  */
object Default extends Newtype[Document] {
  val id: ShapeId = ShapeId("smithy.api", "default")
  val hints: Hints = Hints(
    smithy.api.Documentation("Provides a structure member with a default value. When added to root\nlevel shapes, requires that every targeting structure member defines the\nsame default value on the member or sets a default of null.\n\nThis trait can currently only be used in Smithy 2.0 models."),
    smithy.api.Trait(selector = Some(":is(simpleType, list, map, structure > member :test(> :is(simpleType, list, map)))"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
  ).lazily
  val underlyingSchema: Schema[Document] = document.withId(id).addHints(hints)
  implicit val schema: Schema[Default] = recursive(bijection(underlyingSchema, asBijection))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy