fix(document-builder): accept multi-digit OpenAPI version segments#3874
Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom Apr 22, 2026
Merged
Conversation
setOpenAPIVersion validated the argument with `/^\d\.\d\.\d$/`, which requires exactly one digit per segment. OpenAPI spec versions follow semver (e.g. `3.0.10`, `3.10.0`, and hypothetically `10.x.x`), so a caller trying to set `3.0.10` was silently rejected and the default was kept, with only a warn-level log to signal the failure. Switch to `/^\d+\.\d+\.\d+$/` so each segment may have any number of digits. Malformed inputs (`3.0`, `3.0.0-beta`, …) still fall through to the existing warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (DocumentBuilder).
What is the current behavior?
DocumentBuilder.setOpenAPIVersionvalidates its argument with:The regex requires exactly one digit per segment. OpenAPI Specification versions follow semver —
3.0.xhas already reached3.0.4, a future3.0.10or3.10.0would be entirely valid — but any of those would be silently rejected today with only a warn-level log, and the default version on the document would be kept.Minimal repro:
What is the new behavior?
Widened the regex to
/^\d+\.\d+\.\d+$/, so each segment may contain any non-negative integer. Genuinely malformed inputs (3.0,3.0.0-beta, …) still fall through to the existing warning.Additional context
Added three unit-test cases to
test/document-builder.spec.tscovering:3.1.0) — regression guard.3.0.10,3.10.0,10.20.30).