Skip to content

Commit e8cf9fc

Browse files
sample(): update swagger and graphql code first samples
1 parent 2879dc6 commit e8cf9fc

10 files changed

Lines changed: 210 additions & 132 deletions

File tree

sample/11-swagger/nest-cli.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"compilerOptions": {
3-
"plugins": ["@nestjs/swagger/plugin"]
3+
"plugins": [
4+
{
5+
"name": "@nestjs/swagger",
6+
"options": {
7+
"introspectComments": true
8+
}
9+
}
10+
]
411
}
512
}

sample/11-swagger/package-lock.json

Lines changed: 32 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/11-swagger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@nestjs/common": "7.4.4",
2323
"@nestjs/core": "7.4.4",
2424
"@nestjs/platform-express": "7.4.4",
25-
"@nestjs/swagger": "4.6.0",
25+
"@nestjs/swagger": "4.6.1",
2626
"class-transformer": "0.3.1",
2727
"class-validator": "0.12.2",
2828
"reflect-metadata": "0.1.13",

sample/11-swagger/src/cats/cats.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
ApiBearerAuth,
44
ApiOperation,
55
ApiResponse,
6-
ApiTags,
6+
ApiTags
77
} from '@nestjs/swagger';
88
import { CatsService } from './cats.service';
9-
import { Cat } from './classes/cat.class';
109
import { CreateCatDto } from './dto/create-cat.dto';
10+
import { Cat } from './entities/cat.entity';
1111

1212
@ApiBearerAuth()
1313
@ApiTags('cats')

sample/11-swagger/src/cats/cats.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
2-
import { Cat } from './classes/cat.class';
32
import { CreateCatDto } from './dto/create-cat.dto';
3+
import { Cat } from './entities/cat.entity';
44

55
@Injectable()
66
export class CatsService {

sample/11-swagger/src/cats/classes/cat.class.ts renamed to sample/11-swagger/src/cats/entities/cat.entity.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { ApiProperty } from '@nestjs/swagger';
22

33
export class Cat {
4-
@ApiProperty({ example: 'Kitty', description: 'The name of the Cat' })
4+
/**
5+
* The name of the Cat
6+
* @example Kitty
7+
*/
58
name: string;
69

710
@ApiProperty({ example: 1, description: 'The age of the Cat' })
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"compilerOptions": {
3-
"plugins": ["@nestjs/graphql/plugin"]
3+
"plugins": [
4+
{
5+
"name": "@nestjs/graphql",
6+
"options": {
7+
"introspectComments": true
8+
}
9+
}
10+
]
411
}
512
}

0 commit comments

Comments
 (0)