Skip to content

Commit 33df8db

Browse files
committed
docs: add edit user data request to swagger API
1 parent 3313b6d commit 33df8db

File tree

7 files changed

+57
-3
lines changed

7 files changed

+57
-3
lines changed

src/main/docs/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
title: 'Clean Node API',
99
description:
1010
'API of surveys in NodeJs using Typescript, TDD, Clean Architecture, Design Patterns and SOLID principles.',
11-
version: '1.4.0',
11+
version: '1.5.0',
1212
termsOfService:
1313
'https://github.com/DanielAraldi/clean-node-api/blob/main/LICENSE',
1414
contact: {
@@ -21,7 +21,7 @@ export default {
2121
},
2222
},
2323
servers: [{ url: '/api' }],
24-
tags: [{ name: 'Login' }, { name: 'Survey' }],
24+
tags: [{ name: 'Login' }, { name: 'Survey' }, { name: 'Account' }],
2525
paths,
2626
schemas,
2727
components,

src/main/docs/paths.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import {
2+
accountPath,
23
loginPath,
34
signUpPath,
45
refreshTokenPath,
56
surveyPath,
67
surveyResultPath,
78
} from './paths/';
89

9-
// API routes
1010
export default {
11+
'/account/edit': accountPath,
1112
'/login': loginPath,
1213
'/signup': signUpPath,
1314
'/refresh': refreshTokenPath,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export const accountPath = {
2+
put: {
3+
security: [{ apiKeyAuth: [] }],
4+
tags: ['Account'],
5+
summary: 'Update for name and e-mail.',
6+
description: 'Change name and e-mail user. Made only by logged in users.',
7+
requestBody: {
8+
content: {
9+
'application/json': {
10+
schema: {
11+
$ref: '#/schemas/accountEditParams',
12+
},
13+
},
14+
},
15+
},
16+
responses: {
17+
204: {
18+
description: 'Request made successfully, your data was edited!',
19+
},
20+
403: {
21+
$ref: '#/components/forbidden',
22+
},
23+
404: {
24+
$ref: '#/components/notFound',
25+
},
26+
500: {
27+
$ref: '#/components/serverError',
28+
},
29+
},
30+
},
31+
};

src/main/docs/paths/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './account-path';
12
export * from './login-path';
23
export * from './refresh-token-path';
34
export * from './signup-path';

src/main/docs/schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
accountSchema,
3+
accountEditParamsSchema,
34
loginParamsSchema,
45
signUpParamsSchema,
56
errorSchema,
@@ -17,6 +18,7 @@ import {
1718

1819
export default {
1920
account: accountSchema,
21+
accountEditParams: accountEditParamsSchema,
2022
loginParams: loginParamsSchema,
2123
signUpParams: signUpParamsSchema,
2224
refreshToken: refreshTokenSchema,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export const accountEditParamsSchema = {
2+
type: 'object',
3+
properties: {
4+
email: {
5+
type: 'string',
6+
nullable: true,
7+
},
8+
name: {
9+
type: 'string',
10+
nullable: true,
11+
},
12+
},
13+
required: ['email', 'name'],
14+
example: {
15+
16+
name: null,
17+
},
18+
};

src/main/docs/schemas/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './account-edit-params-schema';
12
export * from './account-schema';
23
export * from './error-schema';
34
export * from './login-params-schema';

0 commit comments

Comments
 (0)