Skip to content

Commit

Permalink
Merge da97fbf into 08445f1
Browse files Browse the repository at this point in the history
  • Loading branch information
ludohenin committed Dec 1, 2018
2 parents 08445f1 + da97fbf commit 6b7ec02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -12,6 +12,7 @@ import {
getFilterSchemaFor,
getWhereSchemaFor,
patch,
put,
del,
requestBody,
} from '@loopback/rest';
Expand Down Expand Up @@ -109,6 +110,20 @@ export class <%= className %>Controller {
await this.<%= repositoryNameCamel %>.updateById(id, <%= modelVariableName %>);
}

@put('<%= httpPathName %>/{id}', {
responses: {
'204': {
description: '<%= modelName %> PUT success',
},
},
})
async replaceById(
@param.path.<%= idType %>('id') id: <%= idType %>,
@requestBody() <%= modelVariableName %>: <%= modelName %>,
): Promise<void> {
await this.<%= repositoryNameCamel %>.replaceById(id, <%= modelVariableName %>);
}

@del('<%= httpPathName %>/{id}', {
responses: {
'204': {
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/test/integration/generators/controller.integration.js
Expand Up @@ -318,6 +318,18 @@ function checkRestCrudContents() {
assert.fileContent(expectedFile, regex);
});

// @put - replaceById
const putReplaceByIdRegEx = [
/\@put\('\/product-reviews\/{id}'/,
/responses: {/,
/'204': {/,
/description: 'ProductReview PUT success'/,
/async replaceById\(\s{1,}\@param.path.number\('id'\) id: number,\s{1,}\@requestBody\(\) productReview: ProductReview,\s+\)/,
];
putReplaceByIdRegEx.forEach(regex => {
assert.fileContent(expectedFile, regex);
});

// @del - deleteById
const deleteByIdRegEx = [
/\@del\('\/product-reviews\/{id}', {/,
Expand Down

0 comments on commit 6b7ec02

Please sign in to comment.