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

alloy.StructurePattern.scala Maven / Gradle / Ivy

There is a newer version: 0.19.0-41-91762fb
Show newest version
package alloy

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

final case class StructurePattern(pattern: String, target: ShapeId)

object StructurePattern extends ShapeTag.Companion[StructurePattern] {
  val id: ShapeId = ShapeId("alloy", "structurePattern")

  val hints: Hints = Hints(
    smithy.api.Trait(selector = Some("string"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
  ).lazily

  // constructor using the original order from the spec
  private def make(pattern: String, target: ShapeId): StructurePattern = StructurePattern(pattern, target)

  implicit val schema: Schema[StructurePattern] = recursive(struct(
    string.required[StructurePattern]("pattern", _.pattern),
    string.refined[ShapeId](smithy.api.IdRef(selector = "structure", failWhenMissing = None, errorMessage = None)).required[StructurePattern]("target", _.target),
  )(make).withId(id).addHints(hints))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy