Numeric types
numeric
Section titled “numeric”Any numeric value, equivalent to number
in JSON Schema. The base type for all numeric types.
A JSON example of this model.
// Scale 0100
// Scale 1100.5
// Negative, scale 2-100.5
The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: numeric.yamltype: numberdescription: Any numeric value
integer
Section titled “integer”A whole number without decimals, equivalent to integer
in JSON Schema.
A JSON example of this model.
// Positive42
// Negative-42
The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: integer.yamltype: integerdescription: A whole number without decimals
decimalString
Section titled “decimalString”A decimal number (with variable scale) encoded as a string, to avoid floating point issues.
A JSON example of this model.
// Scale 0"100"
// Scale 1"100.5"
// Negative, scale 2"-100.50"
The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: decimalString.yamltype: stringexamples: - "-100.5" - "100.5" - "100"pattern: ^-?[0-9]+\.?[0-9]*$description: A decimal number (with variable scale) encoded as a string, to avoid floating point issues
The TypeSpec code for this model.
/** A decimal number (with variable scale) encoded as a string, to avoid floating point issues */@pattern( "^-?[0-9]+\\.?[0-9]*$", "Must be a valid decimal number represented as a string")@example("100", #{ title: "Scale 0" })@example("100.5", #{ title: "Scale 1" })@example("-100.5", #{ title: "Negative, scale 2" })scalar decimalString extends string;
Other numeric types
Section titled “Other numeric types”TypeSpec supports several other numeric types, including float
and decimal
. A full list of these types can be found in the TypeSpec documentation.