Repository: nestjs/swagger
Pull request #2909 (2024-04-05 16:21:37)

fix: exclusive minimum and exclusive maximum are numbers
Reopening https://github.com/nestjs/swagger/issues/1162 from @zobzn. 
Originally, the PR couldn't be merged as the OpenAPI Validator didn't support the new spec. https://github.com/nestjs/swagger/pull/1167#issuecomment-801892227
More than three years on, I'm hoping this is no longer an issue. 

## PR Checklist
Please check if your PR fulfills the following requirements:

- [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)


## PR Type
What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->
- [x] Bugfix
- [x] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Other... Please describe:

## What is the current behavior?
Issue Number: https://github.com/nestjs/swagger/issues/1162

## What is the new behavior?
`exclusiveMinimum` and `exclusiveMaximum` can now be provided as either a bool or number, to support the newer spec.

## Does this PR introduce a breaking change?
- [ ] Yes
- [x] No

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->


## Other information



Patch:
diff --git a/lib/interfaces/open-api-spec.interface.ts b/lib/interfaces/open-api-spec.interface.ts
index 2cbfe64f..8686e071 100644
--- a/lib/interfaces/open-api-spec.interface.ts
+++ b/lib/interfaces/open-api-spec.interface.ts
@@ -219,9 +219,9 @@ export interface SchemaObject {
   title?: string;
   multipleOf?: number;
   maximum?: number;
-  exclusiveMaximum?: boolean;
+  exclusiveMaximum?: boolean | number;
   minimum?: number;
-  exclusiveMinimum?: boolean;
+  exclusiveMinimum?: boolean | number;
   maxLength?: number;
   minLength?: number;
   pattern?: string;


Test patch:
diff --git a/e2e/api-spec.json b/e2e/api-spec.json
index a5d20add..d9b8ec9d 100644
--- a/e2e/api-spec.json
+++ b/e2e/api-spec.json
@@ -286,10 +286,8 @@
             "required": true,
             "in": "query",
             "schema": {
-              "minimum": 0,
-              "maximum": 10000,
-              "exclusiveMaximum": true,
-              "exclusiveMinimum": true,
+              "exclusiveMinimum": 0,
+              "exclusiveMaximum": 10000,
               "title": "Page",
               "format": "int32",
               "default": 0,
@@ -483,10 +481,8 @@
             "in": "query",
             "required": true,
             "schema": {
-              "minimum": 0,
-              "maximum": 10000,
-              "exclusiveMaximum": true,
-              "exclusiveMinimum": true,
+              "exclusiveMinimum": 0,
+              "exclusiveMaximum": 10000,
               "title": "Page",
               "format": "int32",
               "default": 0,
diff --git a/e2e/src/cats/dto/pagination-query.dto.ts b/e2e/src/cats/dto/pagination-query.dto.ts
index a837af95..9dcb62bc 100644
--- a/e2e/src/cats/dto/pagination-query.dto.ts
+++ b/e2e/src/cats/dto/pagination-query.dto.ts
@@ -8,11 +8,9 @@ export enum LettersEnum {
 
 export class PaginationQuery {
   @ApiProperty({
-    minimum: 0,
-    maximum: 10000,
+    exclusiveMinimum: 0,
+    exclusiveMaximum: 10000,
     title: 'Page',
-    exclusiveMaximum: true,
-    exclusiveMinimum: true,
     format: 'int32',
     default: 0
   })