Skip to content

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.yaml
type: number
description: A numeric value

integer

A whole number without decimals, equivalent to integer in JSON Schema.

$schema: https://json-schema.org/draft/2020-12/schema
$id: integer.yaml
type: integer
description: A whole number without decimals

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.yaml
type: string
pattern: "^-?[0-9]+\.?[0-9]*$"
description: A decimal number (with variable scale) encoded as a string

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.