Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Preserve precision of decimal validation bounds - #3455

Open
6londe wants to merge 1 commit into
springdoc:mainfrom
6londe:fix/decimal-constraint-schema-bounds
Open

6londe wants to merge 1 commit into
springdoc:mainfrom
6londe:fix/decimal-constraint-schema-bounds

Conversation

@6londe

@6londe 6londe commented Nov 28, 2026

Copy link
Copy Markdown

Problem

Inclusive @DecimalMin and @DecimalMax on numeric request parameters lose precision in /v3/api-docs because the annotation values go through double before becoming BigDecimal. On Spring Boot 4.2.0 and springdoc 3.2.2-SNAPSHOT, a minimum of 0.10000000000000000001 becomes 0.1.

Parse the annotation strings directly as BigDecimal. The added Spring MVC controller reproduces the issue for both OpenAPI 3.0 and 3.1. The tests read the generated JSON as exact decimals and also cover ordinary bounds.

Validation

With JDK 21, run:

./mvnw -pl springdoc-openapi-starter-webmvc-api -am -Dtest=DecimalBoundsTest -Dsurefire.failIfNoSpecifiedTests=false test
./mvnw -pl springdoc-openapi-starter-webmvc-api -am test

The unmodified source failed both precision cases and passed both ordinary cases. All 764 tests in the common and WebMVC API modules passed with the fix. Local Maven settings mapped the Spring snapshot and milestone repository IDs to Maven Central for released dependencies. Coverage is limited to inclusive bounds in the generated API document.

AI disclosure

Codex investigated, implemented, and tested this contribution under the contributor's standing authorization. It has yet to receive a human review.

Parse inclusive DecimalMin and DecimalMax annotation values directly as BigDecimal to preserve numeric bounds in generated OpenAPI schemas.

This branch has not been deployed

No deployments
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.

1 participant