alloy.proto.ProtoIndex.scala Maven / Gradle / Ivy
package alloy.proto
import smithy4s.Hints
import smithy4s.Newtype
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.int
import smithy4s.schema.Schema.recursive
/** Marks an explicit index to be used for a structure member when it is
* interpreted as protobuf. For example:
*
* structure Test { {@literal @}protoIndex(2) str: String }
*
* Is equivalent to:
*
* message Test { string str = 2 }
*/
object ProtoIndex extends Newtype[Int] {
val id: ShapeId = ShapeId("alloy.proto", "protoIndex")
val hints: Hints = Hints(
smithy.api.Documentation("Marks an explicit index to be used for a structure member when it is\ninterpreted as protobuf. For example:\n\nstructure Test { @protoIndex(2) str: String }\n\nIs equivalent to:\n\nmessage Test { string str = 2 }"),
smithy.api.Trait(selector = Some(":is(structure > member,union > member,enum > member, intEnum > member)"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
).lazily
val underlyingSchema: Schema[Int] = int.withId(id).addHints(hints)
implicit val schema: Schema[ProtoIndex] = recursive(bijection(underlyingSchema, asBijection))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy