Decorators
TypeSpec.Events
Section titled “TypeSpec.Events”@contentType
Section titled “@contentType”Specifies the content type of the event envelope, event body, or event payload.
When applied to an event payload, that field must also have a corresponding @data
decorator.
@TypeSpec.Events.contentType(contentType: valueof string)Target
Section titled “Target”UnionVariant | ModelProperty
Parameters
Section titled “Parameters”| Name | Type | Description | 
|---|---|---|
| contentType | valueof string | 
Examples
Section titled “Examples”@eventsunion MixedEvents {  @contentType("application/json")  message: {    id: string,    text: string,  },}Specify the content type of the event payload.
Section titled “Specify the content type of the event payload.”@eventsunion MixedEvents {  {    done: true,  },  {    done: false,    @data @contentType("text/plain") value: string,  },}Identifies the payload of an event. Only one field in an event can be marked as the payload.
@TypeSpec.Events.dataTarget
Section titled “Target”ModelProperty
Parameters
Section titled “Parameters”None
Examples
Section titled “Examples”@eventsunion MixedEvents {  {    metadata: Record<string>,    @data payload: string,  },}@events
Section titled “@events”Specify that this union describes a set of events.
@TypeSpec.Events.eventsTarget
Section titled “Target”Union
Parameters
Section titled “Parameters”None
Examples
Section titled “Examples”@eventsunion MixedEvents {  pingEvent: string,  doneEvent: "done",}