Complex numbers
OpenAPI does not provide support natively for complex numbers. The highest precision integer type is an integer
with an int64
format, while the highest precision decimal value in the spec is a type number
with a double
format.
To support arbitrary precision numbers, Speakeasy introduces two new formats you can use in your OpenAPI document: bigint
, which represents arbitrary precision integers, and decimal
, which represents arbitrary precision decimal numbers. When these formats are used, the generated SDK will use the language-appropriate types to allow natively interacting with them.
Preserve precision when serializing
Generated SDKs treat bigint
and decimal
values as arbitrary precision and ensure their precision is maintained.
During serialization, however, the value will be cast into the type
of the field, which may result in a loss of precision. To prevent this, avoid using a numeric type
in your OpenAPI document, and rather use the string
type with a bigint
or decimal
format. This ensures that the value is serialized as a string, preserving its full precision, subject to the typical limitations of arbitrary precision decimal values in your language of choice.