Skip to content

Data types (streams)

Defines a model that represents a stream protocol type whose data is described by Type.

The ContentType and BodyType describe how the stream is encoded over the wire, while Type describes the data that the stream contains.

model TypeSpec.Http.Streams.HttpStream<Type, ContentType, BodyType>
NameDescription
TypeThe type of the stream’s data.
ContentTypeThe content type of the stream.
BodyTypeThe underlying wire type of the stream.
NameTypeDescription
contentTypestring
bodyBodyType

Describes a stream of JSON data with one JSON object per line and sets the content type to application/jsonl.

The JSON data is described by Type.

model TypeSpec.Http.Streams.JsonlStream<Type>
NameDescription
TypeThe set of models describing the JSON data in the stream.
model Message {
id: string;
text: string;
}
@TypeSpec.Events.events
union Events {
Message,
}
op subscribe(): JsonlStream<Events>;
NameTypeDescription
contentType"application/jsonl"
bodystring