-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(cli): update controller template to enable filter for findById endpoint #4114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,10 @@ export class <%= className %>Controller { | |
description: 'Array of <%= modelName %> model instances', | ||
content: { | ||
'application/json': { | ||
schema: {type: 'array', items: getModelSchemaRef(<%= modelName %>)}, | ||
schema: { | ||
type: 'array', | ||
items: getModelSchemaRef(<%= modelName %>, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -108,12 +111,19 @@ export class <%= className %>Controller { | |
responses: { | ||
'200': { | ||
description: '<%= modelName %> model instance', | ||
content: {'application/json': {schema: getModelSchemaRef(<%= modelName %>)}}, | ||
content: { | ||
'application/json': { | ||
schema: getModelSchemaRef(<%= modelName %>, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
async findById(@param.path.<%= idType %>('id') id: <%= idType %>): Promise<<%= modelName %>> { | ||
return this.<%= repositoryNameCamel %>.findById(id); | ||
async findById( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. based on your question in comment, the response schema should also be updated to
|
||
@param.path.<%= idType %>('id') id: <%= idType %>, | ||
@param.query.object('filter', getFilterSchemaFor(<%= modelName %>)) filter?: Filter<<%= modelName %>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we support all filter properties in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See also #3336 Filter on findById is ignoring the where clause. I am concerned that if we describe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
): Promise<<%= modelName %>> { | ||
return this.<%= repositoryNameCamel %>.findById(id, filter); | ||
} | ||
|
||
@patch('<%= httpPathName %>/{id}', { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,10 @@ export class ProductReviewController { | |
description: 'Array of ProductReview model instances', | ||
content: { | ||
'application/json': { | ||
schema: {type: 'array', items: getModelSchemaRef(ProductReview)}, | ||
schema: { | ||
type: 'array', | ||
items: getModelSchemaRef(ProductReview, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -118,12 +121,19 @@ export class ProductReviewController { | |
responses: { | ||
'200': { | ||
description: 'ProductReview model instance', | ||
content: {'application/json': {schema: getModelSchemaRef(ProductReview)}}, | ||
content: { | ||
'application/json': { | ||
schema: getModelSchemaRef(ProductReview, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
async findById(@param.path.number('id') id: number): Promise<ProductReview> { | ||
return this.barRepository.findById(id); | ||
async findById( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@param.path.number('id') id: number, | ||
@param.query.object('filter', getFilterSchemaFor(ProductReview)) filter?: Filter<ProductReview> | ||
): Promise<ProductReview> { | ||
return this.barRepository.findById(id, filter); | ||
} | ||
|
||
@patch('/product-reviews/{id}', { | ||
|
@@ -249,7 +259,10 @@ export class ProductReviewController { | |
description: 'Array of ProductReview model instances', | ||
content: { | ||
'application/json': { | ||
schema: {type: 'array', items: getModelSchemaRef(ProductReview)}, | ||
schema: { | ||
type: 'array', | ||
items: getModelSchemaRef(ProductReview, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -287,12 +300,19 @@ export class ProductReviewController { | |
responses: { | ||
'200': { | ||
description: 'ProductReview model instance', | ||
content: {'application/json': {schema: getModelSchemaRef(ProductReview)}}, | ||
content: { | ||
'application/json': { | ||
schema: getModelSchemaRef(ProductReview, {includeRelations: true}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
async findById(@param.path.number('id') id: number): Promise<ProductReview> { | ||
return this.barRepository.findById(id); | ||
async findById( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@param.path.number('id') id: number, | ||
@param.query.object('filter', getFilterSchemaFor(ProductReview)) filter?: Filter<ProductReview> | ||
): Promise<ProductReview> { | ||
return this.barRepository.findById(id, filter); | ||
} | ||
|
||
@patch('/product-reviews/{id}', { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍