swagger-api / swagger-api/swagger-parser
[Bug]: Loss of Float Precision When Reading Yaml Files
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Description
This happens under all versions of OpenAPI. In the jackson mapper, https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java#L34 the DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS
Affected Version
Latest Versions
Steps to Reproduce
Read any openapi file that has a float somewhere.
- In an example
- In a vendor extension
Expected Behavior
Value is preserved in Java
Actual Behavior
Value loses precision
Logs / Stack Traces
Environment
- Java version:
- Build tool:
- OS:
Additional Context
Checklist
- I have searched the existing issues and this is not a duplicate.
- I have provided sufficient information for maintainers to reproduce the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java at the referenced Jackson mapper configuration. Reproduce the issue by reading an OpenAPI file containing a float in an example or vendor extension, then verify that the value's precision is preserved in Java. Done means float values no longer lose precision when parsed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100