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

fix: make number default to float if format is float or double #154

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

kennethaasan
Copy link
Contributor

What/Why/How?

Schemas with type number should always be sampled with a double or float, and not an integer. According to the OpenAPI spec, the format of a number is either a double or a float.

Reference

https://spec.openapis.org/oas/v3.1.0#data-types

Testing

Screenshots (optional)

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

@kennethaasan
Copy link
Contributor Author

@RomanHotsiy, is this something you can approve?

@RomanHotsiy
Copy link
Member

Oh, I'm not sure. It seems like a big change. Too many real-life usages use number for integers.

I don't think we need to change it.

@kennethaasan
Copy link
Contributor Author

I can understand that. What if I add another check for format === "float" || format === "double"? Then it should definitely default to a floating number.

@RomanHotsiy
Copy link
Member

@kennethaasan yes, totally agree here.

@kennethaasan
Copy link
Contributor Author

Great! Please check now.

@kennethaasan kennethaasan changed the title fix: make number default to float fix: make number default to float if format is float or double Nov 16, 2023
@kennethaasan
Copy link
Contributor Author

@RomanHotsiy, please review again. I would appreciate this getting merged soon!

@RomanHotsiy RomanHotsiy merged commit bad48ef into Redocly:master Dec 4, 2023
@RomanHotsiy
Copy link
Member

Thanks @kennethaasan !

@RomanHotsiy
Copy link
Member

Just published 1.4.0.

@AlexVarchuk please, upgrade Redoc to this version when you have chance. Thanks!

@kennethaasan kennethaasan deleted the number-default-float branch December 5, 2023 09:30
@kennethaasan
Copy link
Contributor Author

FYI @magicmatatjahu @derberg for asyncapi-react

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

Successfully merging this pull request may close these issues.

2 participants