Repository: nestjs/swagger
Pull request #371 (2019-11-03 17:47:36)

fix() add missing properties support (response model)
## PR Checklist
Please check if your PR fulfills the following requirements:

- [ ] 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". -->
```
[ ] 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?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->

Issue Number: N/A


## What is the new behavior?


## Does this PR introduce a breaking change?
```
[ ] Yes
[ ] 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/decorators/api-property.decorator.ts b/lib/decorators/api-property.decorator.ts
index 87569082..2a6f1b08 100644
--- a/lib/decorators/api-property.decorator.ts
+++ b/lib/decorators/api-property.decorator.ts
@@ -51,7 +51,10 @@ export function ApiPropertyOptional(
 }
 
 export function ApiResponseProperty(
-  options: Pick<ApiPropertyOptions, 'type' | 'example'> = {}
+  options: Pick<
+    ApiPropertyOptions,
+    'type' | 'example' | 'format' | 'enum' | 'deprecated'
+  > = {}
 ): PropertyDecorator {
   return ApiProperty({
     readOnly: true,
diff --git a/lib/services/schema-object-factory.ts b/lib/services/schema-object-factory.ts
index b9c0c462..a555389f 100644
--- a/lib/services/schema-object-factory.ts
+++ b/lib/services/schema-object-factory.ts
@@ -206,7 +206,9 @@ export class SchemaObjectFactory {
       return {
         name: metadata.name || key,
         required: metadata.required,
-        $ref
+        schema: {
+          $ref
+        }
       };
     }
     return {
diff --git a/package.json b/package.json
index 94d89643..8b317c6a 100644
--- a/package.json
+++ b/package.json
@@ -40,8 +40,8 @@
     "typescript": "3.6.3"
   },
   "peerDependencies": {
-    "@nestjs/common": "^6.0.0",
-    "@nestjs/core": "^6.0.0",
+    "@nestjs/common": "^6.8.0",
+    "@nestjs/core": "^6.8.0",
     "reflect-metadata": "^0.1.12"
   },
   "lint-staged": {


Test patch:
diff --git a/test/services/schema-object-factory.spec.ts b/test/services/schema-object-factory.spec.ts
index e290fd8e..6105d791 100644
--- a/test/services/schema-object-factory.spec.ts
+++ b/test/services/schema-object-factory.spec.ts
@@ -53,7 +53,9 @@ describe('SchemaObjectFactory', () => {
             }
           },
           profile: {
-            $ref: '#/components/schemas/CreateProfileDto'
+            schema: {
+              $ref: '#/components/schemas/CreateProfileDto'
+            }
           },
           tags: {
             items: {
@@ -106,7 +108,9 @@ describe('SchemaObjectFactory', () => {
             type: 'string'
           },
           parent: {
-            $ref: '#/components/schemas/CreateUserDto'
+            schema: {
+              $ref: '#/components/schemas/CreateUserDto'
+            }
           }
         },
         required: ['firstname', 'lastname', 'parent']