Repository: nestjs/swagger
Pull request #1109 (2020-12-23 02:24:45)

fix: includes additional properties in schema
## 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
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
    - (seems nothing needed to be updated)

## PR Type
What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->
```
[x] Bugfix
[ ] 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?

`additionalProperties` in `ApiProperty` is not moved to `schema` in swagger.json, which is invalid


## What is the new behavior?

shouldm move `additionalProperties` to `schema`

## 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/services/swagger-types-mapper.ts b/lib/services/swagger-types-mapper.ts
index f55de0be..46b8a5ef 100644
--- a/lib/services/swagger-types-mapper.ts
+++ b/lib/services/swagger-types-mapper.ts
@@ -137,6 +137,7 @@ export class SwaggerTypesMapper {
 
   private getSchemaOptionsKeys(): Array<keyof SchemaObject> {
     return [
+      'additionalProperties',
       'minimum',
       'maximum',
       'maxProperties',
diff --git a/package-lock.json b/package-lock.json
index ad32b1aa..d7a1fbb3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12369,15 +12369,15 @@
       }
     },
     "swagger-ui-dist": {
-      "version": "3.38.0",
-      "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.38.0.tgz",
-      "integrity": "sha512-sselV8VY6f1BBauY9Sdmwz0jVaWTnGuHQWei7BaTpiUrLcoEUdmmK5bKefLXiwq+dx//es2S8mOvUS+tcXDsKg==",
+      "version": "3.36.2",
+      "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.36.2.tgz",
+      "integrity": "sha512-jbxorhRC/FKk8yMx5zEbg1A1sXc/vsW2vrDTJ3clmaMr9F12zsy161kwnxjVt/vVkMglDOz+BC8ZMY01toxHwA==",
       "dev": true
     },
     "swagger-ui-express": {
-      "version": "4.1.6",
-      "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.1.6.tgz",
-      "integrity": "sha512-Xs2BGGudvDBtL7RXcYtNvHsFtP1DBFPMJFRxHe5ez/VG/rzVOEjazJOOSc/kSCyxreCTKfJrII6MJlL9a6t8vw==",
+      "version": "4.1.5",
+      "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.1.5.tgz",
+      "integrity": "sha512-hs9OqBu2jwmhYyFUhdTiwurvbZC+bq2XnWmmbYymVdwhgJCcGkLdnqymX24ZYUve2nkYSvKPEDCo20ZF+vyw9A==",
       "dev": true,
       "requires": {
         "swagger-ui-dist": "^3.18.1"
diff --git a/package.json b/package.json
index 5c8801ef..ed3339c3 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
     "reflect-metadata": "0.1.13",
     "release-it": "14.2.2",
     "swagger-parser": "10.0.2",
-    "swagger-ui-express": "4.1.6",
+    "swagger-ui-express": "4.1.5",
     "ts-jest": "26.4.4",
     "typescript": "4.1.3"
   },


Test patch:
diff --git a/e2e/api-spec.json b/e2e/api-spec.json
index 1899cf8c..f0f6550c 100644
--- a/e2e/api-spec.json
+++ b/e2e/api-spec.json
@@ -363,6 +363,15 @@
               "format": "date-time",
               "type": "string"
             }
+          },
+          {
+            "name": "filter",
+            "required": true,
+            "in": "query",
+            "schema": {
+              "additionalProperties": true,
+              "type": "object"
+            }
           }
         ],
         "responses": {
@@ -507,6 +516,15 @@
               "format": "date-time",
               "type": "string"
             }
+          },
+          {
+            "name": "filter",
+            "in": "query",
+            "required": true,
+            "schema": {
+              "additionalProperties": true,
+              "type": "object"
+            }
           }
         ],
         "responses": {
diff --git a/e2e/src/cats/dto/pagination-query.dto.ts b/e2e/src/cats/dto/pagination-query.dto.ts
index a34ad0de..c7c39f4d 100644
--- a/e2e/src/cats/dto/pagination-query.dto.ts
+++ b/e2e/src/cats/dto/pagination-query.dto.ts
@@ -42,6 +42,12 @@ export class PaginationQuery {
   @ApiProperty()
   beforeDate: Date;
 
+  @ApiProperty({
+    type: 'object',
+    additionalProperties: true
+  })
+  filter: Record<string, any>;
+
   static _OPENAPI_METADATA_FACTORY() {
     return {
       sortBy: { type: () => [String] }