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

smithy4s.smithy.rules.ContextParam.scala Maven / Gradle / Ivy

There is a newer version: 0.0.30
Show newest version
package smithy.rules

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

/** Binds the targeted member of an operation's input structure to the named rule-set parameter.
  * The type of the shape targeted by the trait MUST match the parameter type defined in the rule-set.
  * @param name
  *   The rule-set parameter name.
  */
final case class ContextParam(name: String)

object ContextParam extends ShapeTag.Companion[ContextParam] {
  val id: ShapeId = ShapeId("smithy.rules", "contextParam")

  val hints: Hints = Hints(
    smithy.api.Documentation("Binds the targeted member of an operation\'s input structure to the named rule-set parameter.\nThe type of the shape targeted by the trait MUST match the parameter type defined in the rule-set."),
    smithy.api.Unstable(),
    smithy.api.Trait(selector = Some("operation -[input]-> structure > member"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
  ).lazily

  // constructor using the original order from the spec
  private def make(name: String): ContextParam = ContextParam(name)

  implicit val schema: Schema[ContextParam] = recursive(struct(
    string.required[ContextParam]("name", _.name).addHints(smithy.api.Documentation("The rule-set parameter name.")),
  )(make).withId(id).addHints(hints))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy