Skip to content

Commit acaf2de

Browse files
committed
add description
1 parent 251b09a commit acaf2de

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

README.MD

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11

2-
# Swagger for Nest
2+
# Swagger for Nest
3+
4+
### Quick start
5+
6+
- install
7+
```bash
8+
npm install nest-swagger
9+
```
10+
11+
- add swagger.config.json
12+
``` bash
13+
{
14+
"swagger": {
15+
"outputDirectory": "./dist",
16+
"entryFile": "./src/main.ts",
17+
"name": "your app name",
18+
"description": "description",
19+
"license": "MIT",
20+
"produces": ["application/json"],
21+
"version": "0.0.1"
22+
}
23+
}
24+
```
25+
- add npm script
26+
```
27+
"swagger": "swaggerGen -c ./swagger.config.json",
28+
```
29+
- run npm script
30+
```
31+
npm run swagger
32+
```
33+
you can find the output generated `swagger.json` and `swagger.yaml`

test/nestjs/app.controller.ts

+13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Address {
3939
houseNumber: string;
4040
}
4141

42+
class KeyValueDto {
43+
label: string;
44+
value: string;
45+
}
46+
4247
interface Query {
4348
size: number;
4449
index: number;
@@ -74,6 +79,14 @@ export class AppController {
7479
return null;
7580
}
7681

82+
@Get('search')
83+
async search(
84+
@Query('keyword') keyword?: string,
85+
@Query('value') value?: string
86+
): Promise<KeyValueDto[]> {
87+
return null;
88+
}
89+
7790
@Get(':id')
7891
async findOne(@Param('id') id: string): Promise<User> {
7992
return null;

0 commit comments

Comments
 (0)