microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3e669c74c1e16a47afe2b98706bdcf8dad4434af

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

packages/compiler/lib/lib.tsp

158lines · modecode

1namespace TypeSpec;
2
3/**
4 * Represent a byte array
5 */
6scalar bytes;
7
8/**
9 * A numeric type
10 */
11scalar numeric;
12
13/**
14 * A whole number
15 */
16scalar integer extends numeric;
17
18/**
19 * A number with decimal value
20 */
21scalar float extends numeric;
22
23/**
24 * A 64-bit integer. (`-9,223,372,036,854,775,808` to `9,223,372,036,854,775,807`)
25 */
26scalar int64 extends integer;
27
28/**
29 * A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`)
30 */
31scalar int32 extends int64;
32
33/**
34 * A 16-bit integer. (`-32,768` to `32,767`)
35 */
36scalar int16 extends int32;
37
38/**
39 * A 8-bit integer. (`-128` to `127`)
40 */
41scalar int8 extends int16;
42
43/**
44 * A 64-bit unsigned integer (`0` to `18,446,744,073,709,551,615`)
45 */
46scalar uint64 extends integer;
47
48/**
49 * A 32-bit unsigned integer (`0` to `4,294,967,295`)
50 */
51scalar uint32 extends uint64;
52
53/**
54 * A 16-bit unsigned integer (`0` to `65,535`)
55 */
56scalar uint16 extends uint32;
57
58/**
59 * A 8-bit unsigned integer (`0` to `255`)
60 */
61scalar uint8 extends uint16;
62
63/**
64 * An integer that can be serialized to JSON (`−9007199254740991 (−(2^53 − 1))` to `9007199254740991 (2^53 − 1)` )
65 */
66scalar safeint extends int64;
67
68/**
69 * A 32 bit floating point number. (`±1.5 x 10^−45` to `±3.4 x 10^38`)
70 */
71scalar float64 extends float;
72
73/**
74 * A 32 bit floating point number. (`±5.0 × 10^−324` to `±1.7 × 10^308`)
75 */
76scalar float32 extends float64;
77
78/**
79 * A sequence of textual characters.
80 */
81scalar string;
82
83/**
84 * A date on a calendar without a time zone, e.g. "April 10th"
85 */
86scalar plainDate;
87
88/**
89 * A time on a clock without a time zone, e.g. "3:00 am"
90 */
91scalar plainTime;
92
93/**
94 * A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST"
95 */
96scalar zonedDateTime;
97
98/**
99 * A duration/time period. e.g 5s, 10h
100 */
101scalar duration;
102
103/**
104 * Boolean with `true` and `false` values.
105 */
106scalar boolean;
107
108/**
109 * Represent any structured model.(With properties)
110 */
111model object {}
112
113/**
114 * Array model type, equivalent to `T[]`
115 */
116@indexer(integer, T)
117model Array<T> {}
118
119/**
120 * Model with string properties where all the properties have type `T`
121 */
122@indexer(string, T)
123model Record<T> {}
124
125/**
126 * Represent a URI string as described by https://url.spec.whatwg.org/#relative-url-string.
127 */
128@format("url")
129scalar url extends string;
130
131@doc("The template for adding optional properties.")
132@withOptionalProperties
133model OptionalProperties<T> {
134 ...T;
135}
136
137@doc("The template for adding updateable properties.")
138@withUpdateableProperties
139model UpdateableProperties<T> {
140 ...T;
141}
142
143@doc("The template for omitting properties.")
144@withoutOmittedProperties(TKeys)
145model OmitProperties<T, TKeys extends string> {
146 ...T;
147}
148
149@withoutDefaultValues
150model OmitDefaults<T> {
151 ...T;
152}
153
154@doc("The template for setting the default visibility of key properties.")
155@withDefaultKeyVisibility(Visibility)
156model DefaultKeyVisibility<T, Visibility extends string> {
157 ...T;
158}
159