smithy.api.Http.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.int
import smithy4s.schema.Schema.recursive
import smithy4s.schema.Schema.struct
/** Configures the HTTP bindings of an operation.
* @param method
* The HTTP method of the operation.
* @param uri
* The URI pattern of the operation.
*
* Labels defined in the URI pattern are used to bind operation input
* members to the URI.
*/
final case class Http(method: NonEmptyString, uri: NonEmptyString, code: Int = 200)
object Http extends ShapeTag.Companion[Http] {
val id: ShapeId = ShapeId("smithy.api", "http")
val hints: Hints = Hints(
smithy.api.Documentation("Configures the HTTP bindings of an operation."),
smithy.api.Trait(selector = Some("operation"), structurallyExclusive = None, conflicts = None, breakingChanges = Some(List(smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.REMOVE.widen, severity = smithy.api.Severity.ERROR.widen, path = None, message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/method"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/uri"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/code"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.PRESENCE.widen, severity = smithy.api.Severity.DANGER.widen, path = Some("/code"), message = Some("Adding or removing is backward compatible only if the value is the default value of 200"))))),
).lazily
// constructor using the original order from the spec
private def make(method: NonEmptyString, uri: NonEmptyString, code: Int): Http = Http(method, uri, code)
implicit val schema: Schema[Http] = recursive(struct(
NonEmptyString.schema.required[Http]("method", _.method).addHints(smithy.api.Documentation("The HTTP method of the operation.")),
NonEmptyString.schema.required[Http]("uri", _.uri).addHints(smithy.api.Documentation("The URI pattern of the operation.\n\nLabels defined in the URI pattern are used to bind operation input\nmembers to the URI.")),
int.validated(smithy.api.Range(min = Some(scala.math.BigDecimal(100.0)), max = Some(scala.math.BigDecimal(999.0)))).field[Http]("code", _.code).addHints(smithy.api.Default(smithy4s.Document.fromDouble(200.0d))),
)(make).withId(id).addHints(hints))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy