smithy.api.Example.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Document
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.boolean
import smithy4s.schema.Schema.document
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct
final case class Example(title: String, documentation: Option[String] = None, input: Option[Document] = None, output: Option[Document] = None, error: Option[ExampleError] = None, allowConstraintErrors: Option[Boolean] = None)
object Example extends ShapeTag.Companion[Example] {
val id: ShapeId = ShapeId("smithy.api", "Example")
val hints: Hints = Hints(
smithy.api.Private(),
).lazily
// constructor using the original order from the spec
private def make(title: String, documentation: Option[String], input: Option[Document], output: Option[Document], error: Option[ExampleError], allowConstraintErrors: Option[Boolean]): Example = Example(title, documentation, input, output, error, allowConstraintErrors)
implicit val schema: Schema[Example] = struct(
string.required[Example]("title", _.title),
string.optional[Example]("documentation", _.documentation),
document.optional[Example]("input", _.input),
document.optional[Example]("output", _.output),
ExampleError.schema.optional[Example]("error", _.error),
boolean.optional[Example]("allowConstraintErrors", _.allowConstraintErrors),
)(make).withId(id).addHints(hints)
}