alloy.proto.ProtoInlinedOneOf.scala Maven / Gradle / Ivy
package alloy.proto
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.constant
/** This trait can be used to customize the rendering of an
* Union shape during the conversion to Protobuf models.
* Union in Protobuf are typically encoded using `oneOf`.
*
* `oneOf` can only be used within `message` and each of their
* member has an index. This makes them tricky to render.
* One possible solution is to create a synthetic `message` to
* host the `oneOf`, and then use that `message` FQN at use site
* when refering to the Union.
* There is an alternate encoding where you render the `oneOf`
* inside the `message` where it's used. You can only use this encoding
* if the Union is used only inside of one `structure`.
*
* You can use this trait, along with the validator provided, to
* implement this encoding.
*/
final case class ProtoInlinedOneOf()
object ProtoInlinedOneOf extends ShapeTag.Companion[ProtoInlinedOneOf] {
val id: ShapeId = ShapeId("alloy.proto", "protoInlinedOneOf")
val hints: Hints = Hints(
smithy.api.Documentation("This trait can be used to customize the rendering of an\nUnion shape during the conversion to Protobuf models.\nUnion in Protobuf are typically encoded using `oneOf`.\n\n`oneOf` can only be used within `message` and each of their\nmember has an index. This makes them tricky to render.\nOne possible solution is to create a synthetic `message` to\nhost the `oneOf`, and then use that `message` FQN at use site\nwhen refering to the Union.\nThere is an alternate encoding where you render the `oneOf`\ninside the `message` where it\'s used. You can only use this encoding\nif the Union is used only inside of one `structure`.\n\nYou can use this trait, along with the validator provided, to\nimplement this encoding."),
smithy.api.Trait(selector = Some("union"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
).lazily
implicit val schema: Schema[ProtoInlinedOneOf] = constant(ProtoInlinedOneOf()).withId(id).addHints(hints)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy