Numeric types
numeric
Any numeric value, equivalent to number
in JSON Schema. The base type for all numeric types.
$schema: https://json-schema.org/draft/2020-12/schema$id: numeric.yamltype: numberdescription: A numeric value
// Positive100.5
// Negative-100.5
// Zero100
integer
A whole number without decimals, equivalent to integer
in JSON Schema.
$schema: https://json-schema.org/draft/2020-12/schema$id: integer.yamltype: integerdescription: A whole number without decimals
// Positive42
// Negative-42
decimalString
A decimal number (with variable scale) encoded as a string, to avoid floating point issues.
$schema: https://json-schema.org/draft/2020-12/schema$id: decimalString.yamltype: stringpattern: "^-?[0-9]+\.?[0-9]*$"description: A decimal number (with variable scale) encoded as a string
/** 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.50")scalar decimalString extends string;
// Scale 0"100"
// Scale 1"100.5"
// Negative, scale 2"-100.50"
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.