Skip to content
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

number type should accept valid number passed in string #4310

Open
abhiptl opened this issue Jan 17, 2025 · 1 comment
Open

number type should accept valid number passed in string #4310

abhiptl opened this issue Jan 17, 2025 · 1 comment
Labels

Comments

@abhiptl
Copy link

abhiptl commented Jan 17, 2025

Open API Spec as number type and most of the programming language convert into some numeric type(in java it is BigDecimal) which are capable of converting valid number into respective target data type.

But, open API spec document says below

Note that strings containing numbers, such as “17”, are considered strings and not numbers.

I want to understand if we should remove above line or that is expectation?

@handrews
Copy link
Member

@abhiptl this is part of JSON Schema rather than OpenAPI. JSON (and therefore JSON Schema) do not define type conversions or coercions. If you want to use numbers from strings (which is a good way to get around floating point and other limitations of JSON's number type), you use something like "type": "string", "format": "int64" (see the format registry for what formats can be used, and what limitations might be present in support).

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

No branches or pull requests

2 participants