Encoding of types
This document describe how the http library interpret TypeSpec built-in types and how to configure
bytes
Default behavior:
bytes
are serialized asbase64
when used inside a model serialized as JSON- In request or response body it represent a binary payload.
Use @encode
to configure
model Pet { icon: bytes; // Serialize as base64 @encode(BytesKnownEncoding.base64url) // Serialize as base64url other: bytes;}
op read(): Pet;
op download(): bytes; // Return application/octet-streamop upload(@body data: bytes): void; // Accept application/octet-stream
utcDatetime
and offsetDateTime
Default behavior:
- Encoded as
rfc7231
when used in a header - Encoded as
rfc3339
otherwise.
Use @encode
to configure.
TypeSpec | Example payload |
|
|
duration
Default behavior:
- Encoded as
ISO8601
Use @encode
to configure.
TypeSpec | Example payload |
|
|
Numeric types ( int64
, decimal128
, float64
, etc.)
By default numeric types are serialized as a JSON number. However for large types like int64
or decimal128
that cannot be represented in certain languages like JavaScript it is recommended to serialize them as string over the wire.
TypeSpec | Example payload |
|
|