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

smithy.api.Example.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.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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy