Skip to content

Type for money #889

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

Closed
worldmind opened this issue Feb 17, 2017 · 3 comments
Closed

Type for money #889

worldmind opened this issue Feb 17, 2017 · 3 comments

Comments

@worldmind
Copy link

worldmind commented Feb 17, 2017

For money params we need special type, in Python, for example, it named decimal, PostgreSQL has numeric type.

@darrelmiller
Copy link
Member

The semantics of decimal can be added using the format property. It will be included in the format registry that we will be creating #845

@spacether
Copy link

spacether commented Sep 7, 2022

For context here openapi-generator does this for python decimal.Decimal amounts with:

type: string
format: number

@karenetheridge
Copy link
Member

karenetheridge commented Sep 11, 2022

I could almost see a "number" format being useful, to specify strings that contain numeric data, but there's so many ways of representing a number, and some of them might not be suitable for a particular application. Also some numeric representations aren't practical in some languages.

For example, one could start out defining a number format as "any string that can be converted to a number in my language" -- so for perl, the easy way of implementing that is with looks_like_number, which handles values like "2.0", "2.5", "2e-3", "Inf" and "NaN" - but doesn't handle "0xDEADBEEF" or "0x1.23p-4" or "0 but true" (which are all treated internally as numbers without warning). Or in C, one could use atoi() but that doesn't match many numeric forms cleanly either.

tldr: formats like this are best defined locally to an application using a definition, so it can be tailored to the exact needs of that application, framework and language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants