Other core types
boolean
A value that is either true
or false
, equivalent to boolean
in JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: boolean.yamltype: boolean
true
false
Array
An ordered list of values, equivalent to array
in JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: array.yamltype: array
[1, 2, 3]
In TypeSpec, you can specify the type of the values in the array with templating:
/** An array of integers */alias IntegerArray = Array<integer>
This is equivalent to the following JSON Schema:
$id: IntegerArray.yamltype: arrayitems: type: integer
Record
A collection of key-value pairs, equivalent to object
in JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: record.yamltype: object
In TypeSpec, you can specify the type of the values in the record with templating:
/** A record with a string key and an integer value */alias StringIntRecord = Record<integer>
This is equivalent to the following JSON Schema:
$id: StringIntRecord.yamltype: objectadditionalProperties: type: integer
If you want to define specific keys in a record, you can do so with a model
.
null
The null
type, equivalent to null
in JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: null.yamltype: null
null
unknown
The unknown
type accepts any value. It is equivalent to an empty JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: unknown.yaml
All of the following are valid values for the unknown
type:
// String"foo"
// Integer123
// Booleantrue