wbcsd / data-exchange-protocol

The fundamental technical specifications of the PACT Network
https://wbcsd.github.io/data-exchange-protocol/v2/
Other
17 stars 11 forks source link

ADR-0039 Consistent typing of real numbers #98

Open schuur opened 1 month ago

schuur commented 1 month ago

ADR for uniform typing of real numbers, proposal for v3. Backwards incompatible changes.

marleyg commented 1 month ago

I'm a fan of this 👍

scottgifford commented 1 month ago

Agree with standardization, but wondering about the type names. I notice the naming here is inconsistent with JSON schema type naming, which uses integer for integers and number for real numbers. It looks like we are proposing Number for the integer type (which I didn't see defined in the current spec), and Decimal changing from its meaning in the current spec to a new type which is a real number expressed as a string, because it allows clients more control over the precision of that number. Are those names consistent with another standard? If not, they seem confusing to me, vs. e.g. Integer and DecimalString.

schuur commented 1 month ago

@scottgifford: totally agree with your observations on type names.

The tech specs refer to the JavaScript types, like String, Boolean but also Number https://tc39.es/ecma262/#sec-numbers-and-dates (and no Integer). However, in JSON Schema (and by extension OpenAPI 3.1+) there is a distinct integer (and string, boolean) type.

Starting v3 it makes sense in the technical specification to refer to the OpenAPI schema types (string, integer, boolean - all lowercase, denoting standard stuff) and use Decimal or DecimalString for the string formatted real numbers. The Pascal casing already indicates the use of a custom type.