smithy.api.TraitDiffRule.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.struct
/** @param path
* Defines a JSON Pointer to the value to evaluate.
* @param change
* Defines the type of change that is not allowed.
* @param severity
* Defines the severity of the change. Defaults to ERROR if not defined.
* @param message
* Provides a reason why the change is potentially backward incompatible.
*/
final case class TraitDiffRule(change: TraitChangeType, severity: Severity = smithy.api.Severity.ERROR.widen, path: Option[String] = None, message: Option[String] = None)
object TraitDiffRule extends ShapeTag.Companion[TraitDiffRule] {
val id: ShapeId = ShapeId("smithy.api", "TraitDiffRule")
val hints: Hints = Hints(
smithy.api.Private(),
).lazily
// constructor using the original order from the spec
private def make(path: Option[String], change: TraitChangeType, severity: Severity, message: Option[String]): TraitDiffRule = TraitDiffRule(change, severity, path, message)
implicit val schema: Schema[TraitDiffRule] = struct(
string.optional[TraitDiffRule]("path", _.path).addHints(smithy.api.Documentation("Defines a JSON Pointer to the value to evaluate.")),
TraitChangeType.schema.required[TraitDiffRule]("change", _.change).addHints(smithy.api.Documentation("Defines the type of change that is not allowed.")),
Severity.schema.field[TraitDiffRule]("severity", _.severity).addHints(smithy.api.Documentation("Defines the severity of the change. Defaults to ERROR if not defined."), smithy.api.Default(smithy4s.Document.fromString("ERROR"))),
string.optional[TraitDiffRule]("message", _.message).addHints(smithy.api.Documentation("Provides a reason why the change is potentially backward incompatible.")),
)(make).withId(id).addHints(hints)
}