−9007199254740991 (−(253 − 1))
to 9007199254740991 (253 − 1)
| An integer that can be serialized to JSON |
+| `uint64` | `0` to `18,446,744,073,709,551,615` | Unsigned 64-bit integer |
+| `uint32` | `0` to `4,294,967,295` | Unsigned 32-bit integer |
+| `uint16` | `0` to `65,535` | Unsigned 16-bit integer |
+| `uint8` | `0` to `255 ` | Unsigned 8-bit integer |
+| `float32` | ±1.5 x 1045
to ±3.4 x 1038
| A 32 bit floating point number |
+| `float64` | ±5.0 × 10−324
to ±1.7 × 10308
| A 64 bit floating point number |
+| `decimal` | | A decimal number |
+| `decimal128` | 34 decimal digits with an exponent range from `-6143` to `6144` | A 128 bit decimal number |
+
+## Date and time types
+
+| Type | Description |
+| ---------------- | ----------------------------------------------------------------------------------- |
+| `plainDate` | A date on a calendar without a time zone, e.g. "April 10th" |
+| `plainTime` | A time on a clock without a time zone, e.g. "3:00 am" |
+| `utcDateTime` | A date and time in coordinated universal time (UTC), e.g. "1985-04-12T23:20:50.52Z" |
+| `offsetDateTime` | A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST" |
+| `duration` | A duration/time period. e.g 5s, 10h |
+
+## Other core types
+
+| Type | Description |
+| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `bytes` | A sequence of bytes |
+| `string` | A sequence of textual characters |
+| `boolean` | Boolean with `true` and `false` values |
+| `null` | Null value |
+| `ArrayTypeSpec | Example payload |
+ +```tsp +model User { + // Headers + @header("Created-At") createdAtHeader: utcDateTime; + + @header("Created-At-Rfc3339") + @encode(DateTimeKnownEncoding.rfc3339) + createdAtHeaderRfc3339Encoding: utcDateTime; + + // In Json payload + createdAt: utcDateTime; // rfc3339 + + updatedAt: offsetDateTime; // rfc3339 + + @encode(DateTimeKnownEncoding.rfc7231) + createdAtPretty: utcDateTime; // rfc7231 + + @encode(DateTimeKnownEncoding.rfc7231) + updatedAtPretty: offsetDateTime; // rfc7231 + + @encode(DateTimeKnownEncoding.unixTimestamp, int32) + createdAtUnix: utcDateTime; // unixTime +} +``` + + | ++ +```yaml +Created-At: Wed, 12 Oct 2022 07:20:50 GMT +Created-At-Rfc3339: 2022-10-12T07:20:50.52Z +``` + +```json +{ + "createdAt": "2022-10-12T07:20:50.52Z", + "updatedAt": "2022-10-25T07:20:50.52+07:00", + "createdAtPretty": "Wed, 12 Oct 2022 07:20:50 GMT", + "updatedAtPretty": "Tue, 25 Oct 2022 00:20:50 GMT", + "createdAtUnix": 1665559250520 +} +``` + + | +
TypeSpec | Example payload |
+ +```tsp +model User { + runtime: duration; // ISO8601 + + @encode(DurationKnownEncoding.seconds, int32) + runtimeInSecondsInt: duration; // in seconds as an int32 + + @encode(DurationKnownEncoding.seconds, float32) + runtimeInSecondsFloat: duration; // in seconds as a float32 +} +``` + + | ++ +```json +{ + "runtime": "PT5M5S", + "runtimeInSecondsInt": "305", + "runtimeInSecondsFloat": "305.0" +} +``` + + | +