Skip to content

Commit 0788b66

Browse files
committed
refactor: move documentations to separete files
1 parent 17f4684 commit 0788b66

File tree

4 files changed

+62
-53
lines changed

4 files changed

+62
-53
lines changed

src/main/docs/components.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { apiKeyAuthSchema } from './schemas/';
2+
import {
3+
badRequest,
4+
forbidden,
5+
notFound,
6+
serverError,
7+
unanthorized,
8+
} from './components/';
9+
10+
export default {
11+
securitySchemes: {
12+
apiKeyAuth: apiKeyAuthSchema,
13+
},
14+
badRequest,
15+
serverError,
16+
unanthorized,
17+
notFound,
18+
forbidden,
19+
};

src/main/docs/index.ts

+7-53
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
import { loginPath, surveyPath, signUpPath, surveyResultPath } from './paths';
2-
import {
3-
badRequest,
4-
serverError,
5-
unanthorized,
6-
notFound,
7-
forbidden,
8-
} from './components';
9-
import {
10-
loginParamsSchema,
11-
errorSchema,
12-
accountSchema,
13-
surveyAnswerSchema,
14-
surveySchema,
15-
surveysSchema,
16-
apiKeyAuthSchema,
17-
signUpParamsSchema,
18-
addSurveyAnswerSchema,
19-
addSurveyParamsSchema,
20-
saveSurveyParamsSchema,
21-
surveyResultSchema,
22-
} from './schemas';
1+
import paths from './paths';
2+
import components from './components';
3+
import schemas from './schemas';
234

245
export default {
25-
openapi: '3.0.0', // API version
6+
openapi: '3.0.0', // Swagger API version
267
info: {
278
title: 'Clean Node API',
289
description:
@@ -39,34 +20,7 @@ export default {
3920
},
4021
servers: [{ url: '/api' }], // Paths URL
4122
tags: [{ name: 'Login' }, { name: 'Survey' }], // Query titles
42-
paths: {
43-
// API routes
44-
'/login': loginPath,
45-
'/signup': signUpPath,
46-
'/surveys': surveyPath,
47-
'/surveys/{surveyId}/results': surveyResultPath,
48-
},
49-
schemas: {
50-
account: accountSchema,
51-
loginParams: loginParamsSchema,
52-
signUpParams: signUpParamsSchema,
53-
error: errorSchema,
54-
survey: surveySchema,
55-
surveys: surveysSchema,
56-
surveyAnswer: surveyAnswerSchema,
57-
addSurveyAnswer: addSurveyAnswerSchema,
58-
addSurveyParams: addSurveyParamsSchema,
59-
saveSurveyParams: saveSurveyParamsSchema,
60-
surveyResult: surveyResultSchema,
61-
},
62-
components: {
63-
securitySchemes: {
64-
apiKeyAuth: apiKeyAuthSchema,
65-
},
66-
badRequest,
67-
serverError,
68-
unanthorized,
69-
notFound,
70-
forbidden,
71-
},
23+
paths,
24+
schemas,
25+
components,
7226
};

src/main/docs/paths.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { loginPath, signUpPath, surveyPath, surveyResultPath } from './paths/';
2+
3+
// API routes
4+
export default {
5+
'/login': loginPath,
6+
'/signup': signUpPath,
7+
'/surveys': surveyPath,
8+
'/surveys/{surveyId}/results': surveyResultPath,
9+
};

src/main/docs/schemas.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
accountSchema,
3+
loginParamsSchema,
4+
signUpParamsSchema,
5+
errorSchema,
6+
surveySchema,
7+
surveysSchema,
8+
surveyAnswerSchema,
9+
addSurveyAnswerSchema,
10+
addSurveyParamsSchema,
11+
saveSurveyParamsSchema,
12+
surveyResultSchema,
13+
} from './schemas/';
14+
15+
export default {
16+
account: accountSchema,
17+
loginParams: loginParamsSchema,
18+
signUpParams: signUpParamsSchema,
19+
error: errorSchema,
20+
survey: surveySchema,
21+
surveys: surveysSchema,
22+
surveyAnswer: surveyAnswerSchema,
23+
addSurveyAnswer: addSurveyAnswerSchema,
24+
addSurveyParams: addSurveyParamsSchema,
25+
saveSurveyParams: saveSurveyParamsSchema,
26+
surveyResult: surveyResultSchema,
27+
};

0 commit comments

Comments
 (0)