Data types (streams)
TypeSpec.Http.Streams
Section titled âTypeSpec.Http.StreamsâHttpStream
Section titled âHttpStreamâ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>Template Parameters
Section titled âTemplate Parametersâ| Name | Description |
|---|---|
| Type | The type of the streamâs data. |
| ContentType | The content type of the stream. |
| BodyType | The underlying wire type of the stream. |
Properties
Section titled âPropertiesâ| Name | Type | Description |
|---|---|---|
| contentType | string | |
| body | BodyType |
JsonlStream
Section titled âJsonlStreamâ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>Template Parameters
Section titled âTemplate Parametersâ| Name | Description |
|---|---|
| Type | The set of models describing the JSON data in the stream. |
Examples
Section titled âExamplesâmodel Message { id: string; text: string;}
@TypeSpec.Events.eventsunion Events { Message,}
op subscribe(): JsonlStream<Events>;Properties
Section titled âPropertiesâ| Name | Type | Description |
|---|---|---|
| contentType | "application/jsonl" | |
| body | string |