Skip to content

Commit 2ee5942

Browse files
swagger api doc
1 parent 8189af0 commit 2ee5942

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

src/auth/auth.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("Auth Controller", () => {
8383

8484
await controller.signIn(mockUserRequest, mockResponse);
8585

86-
expect(signInSpy).toHaveBeenCalledWith("te@test.com", "Password11@");
86+
expect(signInSpy).toHaveBeenCalledWith("te@test.com", "Password1@");
8787
});
8888
});
8989
});

src/users/users.controller.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,52 @@ import {statusMessage} from '../constant/statusMessage'
88
import { HttpExceptionFilter } from '../utils/http-exception.filter';
99
import { responseData, userData } from '../interface/common';
1010
import { AuthGuard } from '../common/guards/at.guard';
11-
import { ApiResponse } from '@nestjs/swagger';
12-
11+
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
1312

1413

14+
@ApiTags('users')
1515
@Controller("v1/users")
1616
export class UserController {
1717
constructor(private readonly userService: UserService) {}
18-
18+
19+
@ApiOperation({
20+
summary: 'Create user',
21+
description: 'User signup app',
22+
})
23+
@ApiResponse({
24+
status: 200,
25+
description: 'Success! Returns the data.',
26+
content: {
27+
'application/json': {
28+
schema: {
29+
type: 'object',
30+
properties: {
31+
statusCode: { type: 'number', example: 201 },
32+
isSuccess: { type: 'boolean', example: true},
33+
message: { type: 'string', example: 'Record Created' },
34+
data: { type: 'object', example: 'Record Created' }
35+
},
36+
},
37+
example: {
38+
"statusCode": 201,
39+
"isSuccess": true,
40+
"message": "Record Created",
41+
"data": {
42+
"username": "test username",
43+
"first_name": "pradip",
44+
"last_name": "patil",
45+
"email": "pradip@test.com",
46+
"email_code": "DAQJ1",
47+
"password": "4xeuIuIK3XGXHX3xtMBAM4uYeWlWsOg8RC",
48+
"password_reset_code": "122222",
49+
"createdAt": "2023-12-22T04:45:45.710Z",
50+
"updatedAt": "2023-12-22T04:45:45.710Z",
51+
"_id": "6585147f97b06"
52+
}
53+
},
54+
},
55+
},
56+
})
1957
@Public()
2058
@Post()
2159
@UseFilters(new HttpExceptionFilter())
@@ -27,13 +65,12 @@ export class UserController {
2765

2866
// get user
2967
@ApiResponse({ status: 200, description: 'The record has been successfully fetch.'})
30-
@ApiResponse({ status: 403, description: 'Forbidden.'})
68+
@ApiResponse({ status: 403, description: 'Forbidden.'})
3169
@UseGuards(AuthGuard)
3270
@Get()
3371
@UseFilters(new HttpExceptionFilter())
3472
async findAll(): Promise<userData[]> {
3573
return this.userService.findAll();
3674
}
37-
3875
}
3976

0 commit comments

Comments
 (0)