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

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

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

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.boolean
import smithy4s.schema.Schema.recursive
import smithy4s.schema.Schema.struct

/** Marks a trait as a protocol defining trait.
  * 
  * The targeted trait must only be applied to service shapes, must be a
  * structure, and must have the `trait` trait.
  * @param traits
  *   The list of traits that protocol implementations must understand in
  *   order to successfully use the protocol.
  * @param noInlineDocumentSupport
  *   Set to true if inline documents are not supported by this protocol.
  */
final case class ProtocolDefinition(traits: Option[List[TraitShapeId]] = None, @deprecated(message = "Use the `@traitValidators` trait instead", since = "N/A") noInlineDocumentSupport: Option[Boolean] = None)

object ProtocolDefinition extends ShapeTag.Companion[ProtocolDefinition] {
  val id: ShapeId = ShapeId("smithy.api", "protocolDefinition")

  val hints: Hints = Hints(
    smithy.api.Documentation("Marks a trait as a protocol defining trait.\n\nThe targeted trait must only be applied to service shapes, must be a\nstructure, and must have the `trait` trait."),
    smithy.api.Trait(selector = Some("structure[trait|trait]"), 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)))),
  ).lazily

  // constructor using the original order from the spec
  private def make(traits: Option[List[TraitShapeId]], noInlineDocumentSupport: Option[Boolean]): ProtocolDefinition = ProtocolDefinition(traits, noInlineDocumentSupport)

  implicit val schema: Schema[ProtocolDefinition] = recursive(struct(
    TraitShapeIdList.underlyingSchema.optional[ProtocolDefinition]("traits", _.traits).addHints(smithy.api.Documentation("The list of traits that protocol implementations must understand in\norder to successfully use the protocol.")),
    boolean.optional[ProtocolDefinition]("noInlineDocumentSupport", _.noInlineDocumentSupport).addHints(smithy.api.Documentation("Set to true if inline documents are not supported by this protocol."), smithy.api.Deprecated(message = Some("Use the `@traitValidators` trait instead"), since = None)),
  )(make).withId(id).addHints(hints))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy