feat: add exclusiveMinimum and exclusiveMaximum#1843
Open
jefflembeck wants to merge 1 commit intolukeautry:masterfrom
Open
feat: add exclusiveMinimum and exclusiveMaximum#1843jefflembeck wants to merge 1 commit intolukeautry:masterfrom
jefflembeck wants to merge 1 commit intolukeautry:masterfrom
Conversation
2b27af7 to
cadc882
Compare
Add @exclusiveMinimum and @exclusiveMaximum JSDoc annotations for strict inequality bounds (> / <), complementing @minimum/@maximum (>= / <=). Spec output follows each OpenAPI version's JSON Schema draft: - Swagger 2.0 / OAS 3.0: boolean form (minimum: X, exclusiveMinimum: true) - OAS 3.1: numeric form (exclusiveMinimum: X) When both @Minimum and @exclusiveMinimum are present, v2/v3.0 errors; v3.1 emits both. Closes lukeautry#1842
cadc882 to
621264a
Compare
VannaDii
added a commit
to tsoa-next/tsoa-next
that referenced
this pull request
Mar 22, 2026
This branch implements behavior derived from lukeautry/tsoa#1843 in https://github.com/VannaDii/tsoa-next. Summary: - add `@exclusiveMinimum` and `@exclusiveMaximum` support to validator parsing - enforce strict numeric bounds in runtime validation - emit version-correct schema output for Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 - reject inclusive/exclusive conflicts for Swagger 2.0 and OpenAPI 3.0 while allowing coexistence in OpenAPI 3.1 - add metadata, schema, runtime, integration, and docs coverage Tests: - `npm run build` in `packages/runtime` - `npm run build` in `packages/cli` - `npm run prepare-test && npm run typecheck && npx mocha --require ts-node/register --require tsconfig-paths/register unit/swagger/templateHelpers.spec.ts unit/swagger/exclusiveBounds.spec.ts` - `npx mocha --require ts-node/register --require tsconfig-paths/register unit/swagger/definitionsGeneration/definitions.spec.ts unit/swagger/schemaDetails3.spec.ts unit/swagger/schemaDetails31.spec.ts` - `npx mocha --require ts-node/register --require tsconfig-paths/register integration/express-server.spec.ts integration/koa-server.spec.ts integration/hapi-server.spec.ts integration/dynamic-controllers-express-server.spec.ts integration/openapi3-express.spec.ts integration/koa-server-no-additional-allowed.spec.ts`
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.
Add @exclusiveMinimum and @exclusiveMaximum JSDoc annotations for strict inequality bounds (> / <), complementing @minimum/@maximum (>= / <=).
Spec output follows each OpenAPI version's JSON Schema draft:
When both @Minimum and @exclusiveMinimum are present, v2/v3.0 errors; v3.1 emits both.
Closes #1842
All Submissions:
Closing issues
Put
closes #XXXX(where XXXX is the issue number) in your comment to auto-close the issue that your PR fixes.If this is a new feature submission:
Potential Problems With The Approach
because exclusiveMinimum is a boolean modifier on minimum in those spec versions. This PR throws at spec
generation time if both are used together in 2.0/3.0. In OAS 3.1 they are independent numeric values and
can coexist.
combining minimum + exclusiveMinimum, since the spec generators already prevent this for 2.0/3.0 and it's
valid in 3.1.
Test plan
integer and float validation — verifying values above the bound pass, and values equal to the bound are
correctly rejected (the boundary condition for exclusive semantics).
and schemaDetails31.spec.ts (OAS 3.1) verify correct schema output per spec version — boolean form for
2.0/3.0, numeric form for 3.1 — and that combining @Minimum + @exclusiveMinimum throws in 2.0/3.0 but
succeeds in 3.1.
dynamic-controllers, openapi3-express) updated to validate that requests with
exclusiveMinimum/exclusiveMaximum fields pass on valid input and return the correct error messages on
boundary values.