Skip to content

Commit

Permalink
Merge pull request #530 from bestori/master
Browse files Browse the repository at this point in the history
[FIX] Swagger text - plural fix for resources
  • Loading branch information
michaelyali committed Jun 5, 2020
2 parents 115ee2b + 5ccc0a6 commit 68947a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"nps": "5.9.8",
"nps-utils": "1.7.0",
"pg": "7.12.1",
"pluralize": "^8.0.0",
"prettier": "1.18.2",
"pretty-quick": "1.11.1",
"qs": "6.8.0",
Expand Down
15 changes: 8 additions & 7 deletions packages/crud/src/crud/swagger.helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpStatus } from '@nestjs/common';
import { objKeys, isString, isFunction } from '@nestjsx/util';
import { RequestQueryBuilder } from '@nestjsx/crud-request';
const pluralize = require('pluralize');

import { safeRequire } from '../util';
import { R } from './reflection.helper';
Expand All @@ -14,13 +15,13 @@ export const swaggerPkgJson = safeRequire('@nestjs/swagger/package.json');
export class Swagger {
static operationsMap(modelName): { [key in BaseRouteName]: string } {
return {
getManyBase: `Retrieve many ${modelName}`,
getOneBase: `Retrieve one ${modelName}`,
createManyBase: `Create many ${modelName}`,
createOneBase: `Create one ${modelName}`,
updateOneBase: `Update one ${modelName}`,
replaceOneBase: `Replace one ${modelName}`,
deleteOneBase: `Delete one ${modelName}`,
getManyBase: `Retrieve multiple ${pluralize(modelName)}`,
getOneBase: `Retrieve a single ${modelName}`,
createManyBase: `Create multiple ${pluralize(modelName)}`,
createOneBase: `Create a single ${modelName}`,
updateOneBase: `Update a single ${modelName}`,
replaceOneBase: `Replace a single ${modelName}`,
deleteOneBase: `Delete a single ${modelName}`,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/crud/test/crud.decorator.override.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('#crud', () => {
});
it('should return swagger operation', () => {
const operation = Swagger.getOperation(TestController.prototype.getMany);
const expected = { summary: 'Retrieve many TestModel' };
const expected = { summary: 'Retrieve multiple TestModels' };
expect(operation).toMatchObject(expected);
});
it('should return swagger params', () => {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7124,6 +7124,11 @@ please-upgrade-node@^3.2.0:
dependencies:
semver-compare "^1.0.0"

pluralize@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1"
integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==

pn@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
Expand Down

0 comments on commit 68947a8

Please sign in to comment.