-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN, Infinity, and -Infinity for numbers #603
Comments
Can you tell us some more about the use cases where you actually need those values? In my uses I either needed (relatively small) integers or money values, and never a NaN or an infinity would make any sense. Of course I can guess that you have uses for them, but I would like to know some examples. |
These values can occur when requesting computed results, e.g. during Data Aggregation. Failing a request just because some properties have "funny" values wouldn't be acceptable, and mapping these special values to |
In statistics and data analysis an IoT, missing values are quite common. For example, in a data vector contains values for each of N sources, a NaN indicates no data from that source i, while there may be data from other items in the vector. (This is different from a named value in a JSON object not being present.) |
@DavidBiesack would it be sufficient for you to represent "unknown", "NaN", "-Infinity", and "Infinity" all as |
SAS analytics and data representations actually support 28 different missing values which can encode different reasons why a value is missing. (See MISSING! - Understanding and Making the Most of Missing Data for an explanation.) A period Note: I'm not asking that we account specifically for SAS-specific representations in OAS. I'm just voicing that it is important (to us) to allow for string representations for numerics, whether as in the OP or in some other way. |
Wouldn't this be more of a JSON Schema addition? I realize that OAI specifications are not fully JSON Schema compliant but when it comes to formats and types, they pretty much are. That being said, most JSON Schema validators allow custom formats and you could easily achieve this using a custom format. I'm not -1 on this but having a little context never hurt. |
@whitlockjc From a JSON Schema perspective This extension could be as weak as " |
Tackling PR: #741 |
Format
Another alternative is defining and referencing reuse types such as https://github.com/oasis-tcs/odata-openapi/blob/028cf1aeadd054077b23141c500e05ec2c2537fa/examples/odata-definitions.json#L48-L62, so no need to extend the core OpenAPI specification. |
Somehow the authors of the JSON specification forgot the special number values NaN, Infinity, and -Infinity. As a workaround we represent these double values as JSON string values, and declare the corresponding properties as
"type": ["number","string"],
"format":"double"
Is there a best practice to deal with this, and could that become part of the OpenAPI specification or an accompanying document?
The text was updated successfully, but these errors were encountered: