Skip to content

Commit 5e45ae2

Browse files
author
Agnes Lin
committed
feat(cli): add includeRelations flag
1 parent 1cc20c6 commit 5e45ae2

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

packages/cli/generators/controller/templates/src/controllers/controller-rest-template.ts.ejs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export class <%= className %>Controller {
7070
description: 'Array of <%= modelName %> model instances',
7171
content: {
7272
'application/json': {
73-
schema: {type: 'array', items: getModelSchemaRef(<%= modelName %>)},
73+
schema: {
74+
type: 'array',
75+
items: getModelSchemaRef(<%= modelName %>, {includeRelations: true}),
76+
},
7477
},
7578
},
7679
},
@@ -108,7 +111,11 @@ export class <%= className %>Controller {
108111
responses: {
109112
'200': {
110113
description: '<%= modelName %> model instance',
111-
content: {'application/json': {schema: getModelSchemaRef(<%= modelName %>)}},
114+
content: {
115+
'application/json': {
116+
schema: getModelSchemaRef(<%= modelName %>, {includeRelations: true}),
117+
},
118+
},
112119
},
113120
},
114121
})

packages/cli/snapshots/integration/generators/controller.integration.snapshots.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ export class ProductReviewController {
8080
description: 'Array of ProductReview model instances',
8181
content: {
8282
'application/json': {
83-
schema: {type: 'array', items: getModelSchemaRef(ProductReview)},
83+
schema: {
84+
type: 'array',
85+
items: getModelSchemaRef(ProductReview, {includeRelations: true}),
86+
},
8487
},
8588
},
8689
},
@@ -118,7 +121,11 @@ export class ProductReviewController {
118121
responses: {
119122
'200': {
120123
description: 'ProductReview model instance',
121-
content: {'application/json': {schema: getModelSchemaRef(ProductReview)}},
124+
content: {
125+
'application/json': {
126+
schema: getModelSchemaRef(ProductReview, {includeRelations: true}),
127+
},
128+
},
122129
},
123130
},
124131
})
@@ -252,7 +259,10 @@ export class ProductReviewController {
252259
description: 'Array of ProductReview model instances',
253260
content: {
254261
'application/json': {
255-
schema: {type: 'array', items: getModelSchemaRef(ProductReview)},
262+
schema: {
263+
type: 'array',
264+
items: getModelSchemaRef(ProductReview, {includeRelations: true}),
265+
},
256266
},
257267
},
258268
},
@@ -290,7 +300,11 @@ export class ProductReviewController {
290300
responses: {
291301
'200': {
292302
description: 'ProductReview model instance',
293-
content: {'application/json': {schema: getModelSchemaRef(ProductReview)}},
303+
content: {
304+
'application/json': {
305+
schema: getModelSchemaRef(ProductReview, {includeRelations: true}),
306+
},
307+
},
294308
},
295309
},
296310
})

0 commit comments

Comments
 (0)