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 type instead of double for float in java #1602

Closed
wants to merge 3 commits into from

Conversation

kennethaasan
Copy link
Collaborator

Description

  • This PR makes Number the default type instead of Double for the Float constrainer in Java. If the format is not specified when the type is number, it should allow for both float and double formats.

I believe this is a fix because this is technically a bug in Modelina today.

Related issue(s)

Copy link

netlify bot commented Nov 13, 2023

Deploy Preview for modelina canceled.

Name Link
🔨 Latest commit 3a35c84
🔍 Latest deploy log https://app.netlify.com/sites/modelina/deploys/655206f34402720008bccd6f

@kennethaasan kennethaasan self-assigned this Nov 13, 2023
@kennethaasan
Copy link
Collaborator Author

@dlkj, do you agree with this change? I've received this feedback from our Java users.

@coveralls
Copy link

coveralls commented Nov 13, 2023

Pull Request Test Coverage Report for Build 6849276668

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 92.518%

Totals Coverage Status
Change from base Build 6804607892: 0.002%
Covered Lines: 5601
Relevant Lines: 5902

💛 - Coveralls

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dlkj
Copy link
Contributor

dlkj commented Nov 13, 2023

My main concern would be verifying that Number interacts well with common serialization frameworks like Jackson. In Java Number is abstract and represents all numerical types, including integers. I understand where the feedback is coming from, but there isn't a direct one to one mapping of the JSON number to the Java Number.

I'm happy with the current functionality. https://datatracker.ietf.org/doc/html/rfc7159#section-6 acknowledges that implementation are likely to represent numbers as an IEEE double precision floating point number. In Java that is double.

@dlkj
Copy link
Contributor

dlkj commented Nov 13, 2023

We mandated that our uses specify a format for all number types. Either float or double. This ensures that implementations are agreed in what precision will be used in the underlying implementation as JSON number is deliberately ambiguous.

@kennethaasan
Copy link
Collaborator Author

@dlkj, good points. I made Redocly/openapi-sampler#154 instead. Our biggest issue right now is that generated samples from openapi-sampler generate integers instead of floats. After reading both the OpenAPI and AsyncAPI specs, number should default to a float value.

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.

3 participants