@duplojs/http 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/getBody.cjs +22 -0
- package/dist/client/getBody.d.ts +1 -0
- package/dist/client/getBody.mjs +20 -0
- package/dist/client/hooks.cjs +79 -0
- package/dist/client/hooks.d.ts +33 -0
- package/dist/client/hooks.mjs +70 -0
- package/dist/client/httpClient.cjs +153 -0
- package/dist/client/httpClient.d.ts +60 -0
- package/dist/client/httpClient.mjs +130 -0
- package/dist/client/index.cjs +33 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.mjs +9 -0
- package/dist/client/insertParamsInPath.cjs +12 -0
- package/dist/client/insertParamsInPath.d.ts +2 -0
- package/dist/client/insertParamsInPath.mjs +10 -0
- package/dist/client/kind.cjs +9 -0
- package/dist/client/kind.d.ts +6 -0
- package/dist/client/kind.mjs +7 -0
- package/dist/client/promiseRequest.cjs +355 -0
- package/dist/client/promiseRequest.d.ts +98 -0
- package/dist/client/promiseRequest.mjs +332 -0
- package/dist/client/queryToString.cjs +25 -0
- package/dist/client/queryToString.d.ts +2 -0
- package/dist/client/queryToString.mjs +23 -0
- package/dist/client/types/ObjectCanBeEmpty.cjs +2 -0
- package/dist/client/types/ObjectCanBeEmpty.d.ts +4 -0
- package/dist/client/types/ObjectCanBeEmpty.mjs +1 -0
- package/dist/client/types/clientRequestParams.cjs +2 -0
- package/dist/client/types/clientRequestParams.d.ts +51 -0
- package/dist/client/types/clientRequestParams.mjs +1 -0
- package/dist/client/types/clientResponse.cjs +2 -0
- package/dist/client/types/clientResponse.d.ts +34 -0
- package/dist/client/types/clientResponse.mjs +1 -0
- package/dist/client/types/index.cjs +7 -0
- package/dist/client/types/index.d.ts +4 -0
- package/dist/client/types/index.mjs +4 -0
- package/dist/client/types/serverRoute.cjs +2 -0
- package/dist/client/types/serverRoute.d.ts +22 -0
- package/dist/client/types/serverRoute.mjs +1 -0
- package/dist/client/unexpectedResponseError.cjs +44 -0
- package/dist/client/unexpectedResponseError.d.ts +38 -0
- package/dist/client/unexpectedResponseError.mjs +39 -0
- package/dist/core/functionsBuilders/route/default.cjs +10 -9
- package/dist/core/functionsBuilders/route/default.mjs +3 -2
- package/dist/core/functionsBuilders/route/hook.cjs +22 -22
- package/dist/core/functionsBuilders/route/hook.d.ts +2 -2
- package/dist/core/functionsBuilders/route/hook.mjs +2 -2
- package/dist/core/functionsBuilders/steps/create.d.ts +2 -2
- package/dist/core/functionsBuilders/steps/defaults/checkerStep.cjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/checkerStep.mjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/extractStep.cjs +6 -5
- package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +4 -3
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +3 -2
- package/dist/core/functionsBuilders/steps/defaults/processStep.cjs +5 -4
- package/dist/core/functionsBuilders/steps/defaults/processStep.mjs +3 -2
- package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
- package/dist/core/hub/index.cjs +1 -1
- package/dist/core/hub/index.mjs +1 -1
- package/dist/core/index.cjs +37 -34
- package/dist/core/index.mjs +5 -3
- package/dist/core/response/base.cjs +40 -0
- package/dist/core/response/base.d.ts +21 -0
- package/dist/core/response/base.mjs +38 -0
- package/dist/core/response/contract.cjs +2 -2
- package/dist/core/response/contract.d.ts +120 -118
- package/dist/core/response/contract.mjs +2 -2
- package/dist/core/{route/hooks/response.cjs → response/hook.cjs} +4 -3
- package/dist/core/{route/hooks/response.d.ts → response/hook.d.ts} +2 -2
- package/dist/core/{route/hooks/response.mjs → response/hook.mjs} +3 -2
- package/dist/core/response/index.cjs +9 -38
- package/dist/core/response/index.d.ts +3 -20
- package/dist/core/response/index.mjs +3 -38
- package/dist/core/response/predicted.cjs +22 -0
- package/dist/core/response/predicted.d.ts +11 -0
- package/dist/core/response/predicted.mjs +20 -0
- package/dist/core/route/{hooks/index.cjs → hooks.cjs} +2 -3
- package/dist/core/route/{hooks/index.d.ts → hooks.d.ts} +4 -4
- package/dist/core/route/{hooks/index.mjs → hooks.mjs} +2 -2
- package/dist/core/route/index.cjs +4 -4
- package/dist/core/route/index.mjs +1 -1
- package/dist/core/steps/cut.d.ts +3 -3
- package/dist/core/steps/handler.d.ts +3 -3
- package/dist/core/steps/identifier.d.ts +2 -2
- package/dist/core/steps/types/stepFunctionParams.d.ts +2 -2
- package/dist/core/types/forbiddenBigintDataParser.cjs +2 -0
- package/dist/core/types/forbiddenBigintDataParser.d.ts +6 -0
- package/dist/core/types/forbiddenBigintDataParser.mjs +1 -0
- package/dist/core/types/index.cjs +1 -0
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.mjs +1 -0
- package/dist/interfaces/node/createHttpServer.cjs +1 -0
- package/dist/interfaces/node/createHttpServer.d.ts +2 -1
- package/dist/interfaces/node/createHttpServer.mjs +1 -0
- package/dist/interfaces/node/hooks.cjs +16 -13
- package/dist/interfaces/node/hooks.mjs +15 -12
- package/dist/plugins/codeGenerator/index.cjs +0 -3
- package/dist/plugins/codeGenerator/index.mjs +1 -1
- package/dist/plugins/codeGenerator/plugin.cjs +1 -1
- package/dist/plugins/codeGenerator/plugin.mjs +1 -1
- package/dist/plugins/codeGenerator/routeToDataParser.cjs +4 -55
- package/dist/plugins/codeGenerator/routeToDataParser.d.ts +2 -181
- package/dist/plugins/codeGenerator/routeToDataParser.mjs +6 -54
- package/dist/plugins/openApiGenerator/aggregateStepContract.cjs +62 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.d.ts +18 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.mjs +60 -0
- package/dist/plugins/openApiGenerator/index.cjs +17 -0
- package/dist/plugins/openApiGenerator/index.d.ts +7 -0
- package/dist/plugins/openApiGenerator/index.mjs +7 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.cjs +30 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.d.ts +7 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.mjs +28 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.cjs +15 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +18 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.mjs +13 -0
- package/dist/plugins/openApiGenerator/plugin.cjs +90 -0
- package/dist/plugins/openApiGenerator/plugin.d.ts +49 -0
- package/dist/plugins/openApiGenerator/plugin.mjs +88 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +163 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +35 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +161 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.d.ts +19 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.d.ts +22 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.d.ts +1 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/index.cjs +11 -0
- package/dist/plugins/openApiGenerator/types/index.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/index.mjs +8 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.d.ts +31 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.d.ts +1 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.d.ts +4 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.mjs +1 -0
- package/package.json +17 -4
|
@@ -1,186 +1,7 @@
|
|
|
1
1
|
import { type Route } from "../../core/route";
|
|
2
|
-
import { DP
|
|
2
|
+
import { DP } from "@duplojs/utils";
|
|
3
3
|
import { type ResponseContract } from "../../core/response";
|
|
4
4
|
export interface RouteToDataParserParams {
|
|
5
5
|
readonly defaultExtractContract: ResponseContract.Contract;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
8
|
-
readonly value: readonly DString.Digit[];
|
|
9
|
-
readonly errorMessage?: string | undefined;
|
|
10
|
-
readonly identifier?: string | undefined;
|
|
11
|
-
readonly checkers: readonly [];
|
|
12
|
-
}>;
|
|
13
|
-
export declare const responseCodeDataParsers: {
|
|
14
|
-
information: DP.DataParserTemplateLiteral<{
|
|
15
|
-
readonly template: readonly ["1", DP.DataParserLiteral<{
|
|
16
|
-
readonly value: readonly DString.Digit[];
|
|
17
|
-
readonly errorMessage?: string | undefined;
|
|
18
|
-
readonly identifier?: string | undefined;
|
|
19
|
-
readonly checkers: readonly [];
|
|
20
|
-
}>, DP.DataParserLiteral<{
|
|
21
|
-
readonly value: readonly DString.Digit[];
|
|
22
|
-
readonly errorMessage?: string | undefined;
|
|
23
|
-
readonly identifier?: string | undefined;
|
|
24
|
-
readonly checkers: readonly [];
|
|
25
|
-
}>];
|
|
26
|
-
readonly errorMessage?: string | undefined;
|
|
27
|
-
readonly identifier?: string | undefined;
|
|
28
|
-
readonly pattern: RegExp;
|
|
29
|
-
readonly checkers: readonly [];
|
|
30
|
-
}>;
|
|
31
|
-
success: DP.DataParserTemplateLiteral<{
|
|
32
|
-
readonly template: readonly ["2", DP.DataParserLiteral<{
|
|
33
|
-
readonly value: readonly DString.Digit[];
|
|
34
|
-
readonly errorMessage?: string | undefined;
|
|
35
|
-
readonly identifier?: string | undefined;
|
|
36
|
-
readonly checkers: readonly [];
|
|
37
|
-
}>, DP.DataParserLiteral<{
|
|
38
|
-
readonly value: readonly DString.Digit[];
|
|
39
|
-
readonly errorMessage?: string | undefined;
|
|
40
|
-
readonly identifier?: string | undefined;
|
|
41
|
-
readonly checkers: readonly [];
|
|
42
|
-
}>];
|
|
43
|
-
readonly errorMessage?: string | undefined;
|
|
44
|
-
readonly identifier?: string | undefined;
|
|
45
|
-
readonly pattern: RegExp;
|
|
46
|
-
readonly checkers: readonly [];
|
|
47
|
-
}>;
|
|
48
|
-
redirection: DP.DataParserTemplateLiteral<{
|
|
49
|
-
readonly template: readonly ["3", DP.DataParserLiteral<{
|
|
50
|
-
readonly value: readonly DString.Digit[];
|
|
51
|
-
readonly errorMessage?: string | undefined;
|
|
52
|
-
readonly identifier?: string | undefined;
|
|
53
|
-
readonly checkers: readonly [];
|
|
54
|
-
}>, DP.DataParserLiteral<{
|
|
55
|
-
readonly value: readonly DString.Digit[];
|
|
56
|
-
readonly errorMessage?: string | undefined;
|
|
57
|
-
readonly identifier?: string | undefined;
|
|
58
|
-
readonly checkers: readonly [];
|
|
59
|
-
}>];
|
|
60
|
-
readonly errorMessage?: string | undefined;
|
|
61
|
-
readonly identifier?: string | undefined;
|
|
62
|
-
readonly pattern: RegExp;
|
|
63
|
-
readonly checkers: readonly [];
|
|
64
|
-
}>;
|
|
65
|
-
clientError: DP.DataParserTemplateLiteral<{
|
|
66
|
-
readonly template: readonly ["4", DP.DataParserLiteral<{
|
|
67
|
-
readonly value: readonly DString.Digit[];
|
|
68
|
-
readonly errorMessage?: string | undefined;
|
|
69
|
-
readonly identifier?: string | undefined;
|
|
70
|
-
readonly checkers: readonly [];
|
|
71
|
-
}>, DP.DataParserLiteral<{
|
|
72
|
-
readonly value: readonly DString.Digit[];
|
|
73
|
-
readonly errorMessage?: string | undefined;
|
|
74
|
-
readonly identifier?: string | undefined;
|
|
75
|
-
readonly checkers: readonly [];
|
|
76
|
-
}>];
|
|
77
|
-
readonly errorMessage?: string | undefined;
|
|
78
|
-
readonly identifier?: string | undefined;
|
|
79
|
-
readonly pattern: RegExp;
|
|
80
|
-
readonly checkers: readonly [];
|
|
81
|
-
}>;
|
|
82
|
-
serverError: DP.DataParserTemplateLiteral<{
|
|
83
|
-
readonly template: readonly ["5", DP.DataParserLiteral<{
|
|
84
|
-
readonly value: readonly DString.Digit[];
|
|
85
|
-
readonly errorMessage?: string | undefined;
|
|
86
|
-
readonly identifier?: string | undefined;
|
|
87
|
-
readonly checkers: readonly [];
|
|
88
|
-
}>, DP.DataParserLiteral<{
|
|
89
|
-
readonly value: readonly DString.Digit[];
|
|
90
|
-
readonly errorMessage?: string | undefined;
|
|
91
|
-
readonly identifier?: string | undefined;
|
|
92
|
-
readonly checkers: readonly [];
|
|
93
|
-
}>];
|
|
94
|
-
readonly errorMessage?: string | undefined;
|
|
95
|
-
readonly identifier?: string | undefined;
|
|
96
|
-
readonly pattern: RegExp;
|
|
97
|
-
readonly checkers: readonly [];
|
|
98
|
-
}>;
|
|
99
|
-
};
|
|
100
|
-
export declare const responseCodeDataParser: DP.DataParserUnion<{
|
|
101
|
-
readonly options: [DP.DataParserTemplateLiteral<{
|
|
102
|
-
readonly template: readonly ["1", DP.DataParserLiteral<{
|
|
103
|
-
readonly value: readonly DString.Digit[];
|
|
104
|
-
readonly errorMessage?: string | undefined;
|
|
105
|
-
readonly identifier?: string | undefined;
|
|
106
|
-
readonly checkers: readonly [];
|
|
107
|
-
}>, DP.DataParserLiteral<{
|
|
108
|
-
readonly value: readonly DString.Digit[];
|
|
109
|
-
readonly errorMessage?: string | undefined;
|
|
110
|
-
readonly identifier?: string | undefined;
|
|
111
|
-
readonly checkers: readonly [];
|
|
112
|
-
}>];
|
|
113
|
-
readonly errorMessage?: string | undefined;
|
|
114
|
-
readonly identifier?: string | undefined;
|
|
115
|
-
readonly pattern: RegExp;
|
|
116
|
-
readonly checkers: readonly [];
|
|
117
|
-
}>, DP.DataParserTemplateLiteral<{
|
|
118
|
-
readonly template: readonly ["2", DP.DataParserLiteral<{
|
|
119
|
-
readonly value: readonly DString.Digit[];
|
|
120
|
-
readonly errorMessage?: string | undefined;
|
|
121
|
-
readonly identifier?: string | undefined;
|
|
122
|
-
readonly checkers: readonly [];
|
|
123
|
-
}>, DP.DataParserLiteral<{
|
|
124
|
-
readonly value: readonly DString.Digit[];
|
|
125
|
-
readonly errorMessage?: string | undefined;
|
|
126
|
-
readonly identifier?: string | undefined;
|
|
127
|
-
readonly checkers: readonly [];
|
|
128
|
-
}>];
|
|
129
|
-
readonly errorMessage?: string | undefined;
|
|
130
|
-
readonly identifier?: string | undefined;
|
|
131
|
-
readonly pattern: RegExp;
|
|
132
|
-
readonly checkers: readonly [];
|
|
133
|
-
}>, DP.DataParserTemplateLiteral<{
|
|
134
|
-
readonly template: readonly ["3", DP.DataParserLiteral<{
|
|
135
|
-
readonly value: readonly DString.Digit[];
|
|
136
|
-
readonly errorMessage?: string | undefined;
|
|
137
|
-
readonly identifier?: string | undefined;
|
|
138
|
-
readonly checkers: readonly [];
|
|
139
|
-
}>, DP.DataParserLiteral<{
|
|
140
|
-
readonly value: readonly DString.Digit[];
|
|
141
|
-
readonly errorMessage?: string | undefined;
|
|
142
|
-
readonly identifier?: string | undefined;
|
|
143
|
-
readonly checkers: readonly [];
|
|
144
|
-
}>];
|
|
145
|
-
readonly errorMessage?: string | undefined;
|
|
146
|
-
readonly identifier?: string | undefined;
|
|
147
|
-
readonly pattern: RegExp;
|
|
148
|
-
readonly checkers: readonly [];
|
|
149
|
-
}>, DP.DataParserTemplateLiteral<{
|
|
150
|
-
readonly template: readonly ["4", DP.DataParserLiteral<{
|
|
151
|
-
readonly value: readonly DString.Digit[];
|
|
152
|
-
readonly errorMessage?: string | undefined;
|
|
153
|
-
readonly identifier?: string | undefined;
|
|
154
|
-
readonly checkers: readonly [];
|
|
155
|
-
}>, DP.DataParserLiteral<{
|
|
156
|
-
readonly value: readonly DString.Digit[];
|
|
157
|
-
readonly errorMessage?: string | undefined;
|
|
158
|
-
readonly identifier?: string | undefined;
|
|
159
|
-
readonly checkers: readonly [];
|
|
160
|
-
}>];
|
|
161
|
-
readonly errorMessage?: string | undefined;
|
|
162
|
-
readonly identifier?: string | undefined;
|
|
163
|
-
readonly pattern: RegExp;
|
|
164
|
-
readonly checkers: readonly [];
|
|
165
|
-
}>, DP.DataParserTemplateLiteral<{
|
|
166
|
-
readonly template: readonly ["5", DP.DataParserLiteral<{
|
|
167
|
-
readonly value: readonly DString.Digit[];
|
|
168
|
-
readonly errorMessage?: string | undefined;
|
|
169
|
-
readonly identifier?: string | undefined;
|
|
170
|
-
readonly checkers: readonly [];
|
|
171
|
-
}>, DP.DataParserLiteral<{
|
|
172
|
-
readonly value: readonly DString.Digit[];
|
|
173
|
-
readonly errorMessage?: string | undefined;
|
|
174
|
-
readonly identifier?: string | undefined;
|
|
175
|
-
readonly checkers: readonly [];
|
|
176
|
-
}>];
|
|
177
|
-
readonly errorMessage?: string | undefined;
|
|
178
|
-
readonly identifier?: string | undefined;
|
|
179
|
-
readonly pattern: RegExp;
|
|
180
|
-
readonly checkers: readonly [];
|
|
181
|
-
}>];
|
|
182
|
-
readonly errorMessage?: string | undefined;
|
|
183
|
-
readonly identifier?: string | undefined;
|
|
184
|
-
readonly checkers: readonly [];
|
|
185
|
-
}>;
|
|
186
|
-
export declare function routeToDataParser(route: Route, params: RouteToDataParserParams): DP.DataParser;
|
|
7
|
+
export declare function routeToDataParser(route: Route, params: RouteToDataParserParams): DP.DataParser[];
|
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
import { stepsToDataParser } from './stepsToDataParser.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { pipe, O, innerPipe, A, DP } from '@duplojs/utils';
|
|
3
3
|
|
|
4
|
-
const digitDataParser = DP.literal(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]).setIdentifier("Digit");
|
|
5
|
-
const responseCodeDataParsers = {
|
|
6
|
-
information: DP.templateLiteral([
|
|
7
|
-
"1",
|
|
8
|
-
digitDataParser,
|
|
9
|
-
digitDataParser,
|
|
10
|
-
]),
|
|
11
|
-
success: DP.templateLiteral([
|
|
12
|
-
"2",
|
|
13
|
-
digitDataParser,
|
|
14
|
-
digitDataParser,
|
|
15
|
-
]),
|
|
16
|
-
redirection: DP.templateLiteral([
|
|
17
|
-
"3",
|
|
18
|
-
digitDataParser,
|
|
19
|
-
digitDataParser,
|
|
20
|
-
]),
|
|
21
|
-
clientError: DP.templateLiteral([
|
|
22
|
-
"4",
|
|
23
|
-
digitDataParser,
|
|
24
|
-
digitDataParser,
|
|
25
|
-
]),
|
|
26
|
-
serverError: DP.templateLiteral([
|
|
27
|
-
"5",
|
|
28
|
-
digitDataParser,
|
|
29
|
-
digitDataParser,
|
|
30
|
-
]),
|
|
31
|
-
};
|
|
32
|
-
const responseCodeDataParser = DP.union([
|
|
33
|
-
responseCodeDataParsers.information,
|
|
34
|
-
responseCodeDataParsers.success,
|
|
35
|
-
responseCodeDataParsers.redirection,
|
|
36
|
-
responseCodeDataParsers.clientError,
|
|
37
|
-
responseCodeDataParsers.serverError,
|
|
38
|
-
]).setIdentifier("ResponseCode");
|
|
39
4
|
function routeToDataParser(route, params) {
|
|
40
5
|
return pipe([
|
|
41
6
|
...route.definition.preflightSteps,
|
|
@@ -50,25 +15,12 @@ function routeToDataParser(route, params) {
|
|
|
50
15
|
return select(O.entry(key, DP.object(value)));
|
|
51
16
|
}
|
|
52
17
|
return skip();
|
|
53
|
-
}), O.fromEntries)), ({ endpointContract, entrypointContract }) => DP.object({
|
|
18
|
+
}), O.fromEntries)), ({ endpointContract, entrypointContract }) => A.map(route.definition.paths, (path) => DP.object({
|
|
54
19
|
method: DP.literal(route.definition.method),
|
|
55
|
-
path: DP.literal(
|
|
20
|
+
path: DP.literal(path),
|
|
56
21
|
...entrypointContract,
|
|
57
|
-
responses: DP.union(
|
|
58
|
-
|
|
59
|
-
code: responseCodeDataParser,
|
|
60
|
-
information: DP.string(),
|
|
61
|
-
body: DP.unknown(),
|
|
62
|
-
fromHook: DP.literal(true),
|
|
63
|
-
}),
|
|
64
|
-
DP.object({
|
|
65
|
-
code: responseCodeDataParsers.serverError,
|
|
66
|
-
information: DP.string(),
|
|
67
|
-
body: DP.unknown(),
|
|
68
|
-
}),
|
|
69
|
-
...endpointContract,
|
|
70
|
-
]),
|
|
71
|
-
}));
|
|
22
|
+
responses: DP.union(endpointContract),
|
|
23
|
+
})));
|
|
72
24
|
}
|
|
73
25
|
|
|
74
|
-
export {
|
|
26
|
+
export { routeToDataParser };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../core/steps/index.cjs');
|
|
4
|
+
var utils = require('@duplojs/utils');
|
|
5
|
+
var process = require('../../core/steps/process.cjs');
|
|
6
|
+
var extract = require('../../core/steps/extract.cjs');
|
|
7
|
+
var presetChecker = require('../../core/steps/presetChecker.cjs');
|
|
8
|
+
var checker = require('../../core/steps/checker.cjs');
|
|
9
|
+
var cut = require('../../core/steps/cut.cjs');
|
|
10
|
+
var handler = require('../../core/steps/handler.cjs');
|
|
11
|
+
|
|
12
|
+
function aggregateStepContract(steps, params) {
|
|
13
|
+
const processContracts = utils.pipe(steps, utils.A.filter(process.processStepKind.has), utils.A.map((element) => aggregateStepContract(element.definition.process.definition.steps, params)), utils.O.to({
|
|
14
|
+
entrypointContract: utils.A.map((result) => result.entrypointContract),
|
|
15
|
+
endpointContract: utils.A.flatMap((result) => result.endpointContract),
|
|
16
|
+
}));
|
|
17
|
+
const entrypointContract = utils.pipe(steps, utils.A.filter(extract.extractStepKind.has), utils.A.map((extractStep) => extractStep.definition.shape), utils.A.concat(processContracts.entrypointContract), utils.A.reduce(utils.A.reduceFrom({
|
|
18
|
+
body: {},
|
|
19
|
+
headers: {},
|
|
20
|
+
params: {},
|
|
21
|
+
query: {},
|
|
22
|
+
}), ({ element: shape, lastValue, nextWithObject }) => utils.pipe(lastValue, utils.O.entries, utils.A.map(([key, accumulatorValue]) => {
|
|
23
|
+
const currentExtractDataParser = shape[key];
|
|
24
|
+
if (utils.DP.dataParserKind.has(accumulatorValue)
|
|
25
|
+
|| !currentExtractDataParser
|
|
26
|
+
|| (!utils.DP.dataParserKind.has(accumulatorValue)
|
|
27
|
+
&& utils.O.countKeys(accumulatorValue) > 1
|
|
28
|
+
&& utils.DP.dataParserKind.has(currentExtractDataParser)
|
|
29
|
+
&& !utils.DP.objectKind.has(currentExtractDataParser))) {
|
|
30
|
+
return utils.O.entry(key, accumulatorValue);
|
|
31
|
+
}
|
|
32
|
+
if (!utils.DP.dataParserKind.has(currentExtractDataParser)) {
|
|
33
|
+
return utils.O.entry(key, {
|
|
34
|
+
...accumulatorValue,
|
|
35
|
+
...currentExtractDataParser,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (utils.DP.identifier(currentExtractDataParser, utils.DP.objectKind)) {
|
|
39
|
+
return utils.O.entry(key, {
|
|
40
|
+
...accumulatorValue,
|
|
41
|
+
...currentExtractDataParser.definition.shape,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return utils.O.entry(key, currentExtractDataParser);
|
|
45
|
+
}), utils.O.fromEntries, (object) => nextWithObject(lastValue, object))));
|
|
46
|
+
const endpointContract = utils.pipe(steps, utils.A.flatMap((step) => utils.P.match(step)
|
|
47
|
+
.when(process.processStepKind.has, () => [])
|
|
48
|
+
.when(extract.extractStepKind.has, ({ definition }) => definition.responseContract ?? params.defaultExtractContract)
|
|
49
|
+
.when(presetChecker.presetCheckerStepKind.has, ({ definition }) => definition.presetChecker.definition.responseContract)
|
|
50
|
+
.when(utils.hasSomeKinds([
|
|
51
|
+
checker.checkerStepKind,
|
|
52
|
+
cut.cutStepKind,
|
|
53
|
+
handler.handlerStepKind,
|
|
54
|
+
]), ({ definition }) => definition.responseContract)
|
|
55
|
+
.exhaustive()), utils.A.concat(processContracts.endpointContract));
|
|
56
|
+
return {
|
|
57
|
+
entrypointContract,
|
|
58
|
+
endpointContract,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.aggregateStepContract = aggregateStepContract;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Steps } from "../../core/steps";
|
|
2
|
+
import { DP } from "@duplojs/utils";
|
|
3
|
+
import type { ResponseCode, ResponseContract } from "../../core/response";
|
|
4
|
+
import type { EntrypointKey } from "./types";
|
|
5
|
+
export interface EndpointRouteResult {
|
|
6
|
+
code: ResponseCode;
|
|
7
|
+
information: string;
|
|
8
|
+
body: DP.DataParser;
|
|
9
|
+
}
|
|
10
|
+
export type EntrypointReduceResult = Record<EntrypointKey, DP.DataParser | Record<string, DP.DataParser>>;
|
|
11
|
+
export interface AggregateStepsResult {
|
|
12
|
+
entrypointContract: EntrypointReduceResult;
|
|
13
|
+
endpointContract: EndpointRouteResult[];
|
|
14
|
+
}
|
|
15
|
+
export interface AggregateStepsParams {
|
|
16
|
+
readonly defaultExtractContract: ResponseContract.Contract;
|
|
17
|
+
}
|
|
18
|
+
export declare function aggregateStepContract(steps: readonly Steps[], params: AggregateStepsParams): AggregateStepsResult;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import '../../core/steps/index.mjs';
|
|
2
|
+
import { pipe, A, O, DP, P, hasSomeKinds } from '@duplojs/utils';
|
|
3
|
+
import { processStepKind } from '../../core/steps/process.mjs';
|
|
4
|
+
import { extractStepKind } from '../../core/steps/extract.mjs';
|
|
5
|
+
import { presetCheckerStepKind } from '../../core/steps/presetChecker.mjs';
|
|
6
|
+
import { checkerStepKind } from '../../core/steps/checker.mjs';
|
|
7
|
+
import { cutStepKind } from '../../core/steps/cut.mjs';
|
|
8
|
+
import { handlerStepKind } from '../../core/steps/handler.mjs';
|
|
9
|
+
|
|
10
|
+
function aggregateStepContract(steps, params) {
|
|
11
|
+
const processContracts = pipe(steps, A.filter(processStepKind.has), A.map((element) => aggregateStepContract(element.definition.process.definition.steps, params)), O.to({
|
|
12
|
+
entrypointContract: A.map((result) => result.entrypointContract),
|
|
13
|
+
endpointContract: A.flatMap((result) => result.endpointContract),
|
|
14
|
+
}));
|
|
15
|
+
const entrypointContract = pipe(steps, A.filter(extractStepKind.has), A.map((extractStep) => extractStep.definition.shape), A.concat(processContracts.entrypointContract), A.reduce(A.reduceFrom({
|
|
16
|
+
body: {},
|
|
17
|
+
headers: {},
|
|
18
|
+
params: {},
|
|
19
|
+
query: {},
|
|
20
|
+
}), ({ element: shape, lastValue, nextWithObject }) => pipe(lastValue, O.entries, A.map(([key, accumulatorValue]) => {
|
|
21
|
+
const currentExtractDataParser = shape[key];
|
|
22
|
+
if (DP.dataParserKind.has(accumulatorValue)
|
|
23
|
+
|| !currentExtractDataParser
|
|
24
|
+
|| (!DP.dataParserKind.has(accumulatorValue)
|
|
25
|
+
&& O.countKeys(accumulatorValue) > 1
|
|
26
|
+
&& DP.dataParserKind.has(currentExtractDataParser)
|
|
27
|
+
&& !DP.objectKind.has(currentExtractDataParser))) {
|
|
28
|
+
return O.entry(key, accumulatorValue);
|
|
29
|
+
}
|
|
30
|
+
if (!DP.dataParserKind.has(currentExtractDataParser)) {
|
|
31
|
+
return O.entry(key, {
|
|
32
|
+
...accumulatorValue,
|
|
33
|
+
...currentExtractDataParser,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (DP.identifier(currentExtractDataParser, DP.objectKind)) {
|
|
37
|
+
return O.entry(key, {
|
|
38
|
+
...accumulatorValue,
|
|
39
|
+
...currentExtractDataParser.definition.shape,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return O.entry(key, currentExtractDataParser);
|
|
43
|
+
}), O.fromEntries, (object) => nextWithObject(lastValue, object))));
|
|
44
|
+
const endpointContract = pipe(steps, A.flatMap((step) => P.match(step)
|
|
45
|
+
.when(processStepKind.has, () => [])
|
|
46
|
+
.when(extractStepKind.has, ({ definition }) => definition.responseContract ?? params.defaultExtractContract)
|
|
47
|
+
.when(presetCheckerStepKind.has, ({ definition }) => definition.presetChecker.definition.responseContract)
|
|
48
|
+
.when(hasSomeKinds([
|
|
49
|
+
checkerStepKind,
|
|
50
|
+
cutStepKind,
|
|
51
|
+
handlerStepKind,
|
|
52
|
+
]), ({ definition }) => definition.responseContract)
|
|
53
|
+
.exhaustive()), A.concat(processContracts.endpointContract));
|
|
54
|
+
return {
|
|
55
|
+
entrypointContract,
|
|
56
|
+
endpointContract,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { aggregateStepContract };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@duplojs/data-parser-tools/toJsonSchema');
|
|
4
|
+
require('./types/index.cjs');
|
|
5
|
+
var plugin = require('./plugin.cjs');
|
|
6
|
+
var routeToOpenApi = require('./routeToOpenApi.cjs');
|
|
7
|
+
var aggregateStepContract = require('./aggregateStepContract.cjs');
|
|
8
|
+
var makeOpenApiRoute = require('./makeOpenApiRoute.cjs');
|
|
9
|
+
var makeOpenApiPage = require('./makeOpenApiPage.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.openApiGeneratorPlugin = plugin.openApiGeneratorPlugin;
|
|
14
|
+
exports.routeToOpenApi = routeToOpenApi.routeToOpenApi;
|
|
15
|
+
exports.aggregateStepContract = aggregateStepContract.aggregateStepContract;
|
|
16
|
+
exports.makeOpenApiRoute = makeOpenApiRoute.makeOpenApiRoute;
|
|
17
|
+
exports.makeOpenApiPage = makeOpenApiPage.makeOpenApiPage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '@duplojs/data-parser-tools/toJsonSchema';
|
|
2
|
+
import './types/index.mjs';
|
|
3
|
+
export { openApiGeneratorPlugin } from './plugin.mjs';
|
|
4
|
+
export { routeToOpenApi } from './routeToOpenApi.mjs';
|
|
5
|
+
export { aggregateStepContract } from './aggregateStepContract.mjs';
|
|
6
|
+
export { makeOpenApiRoute } from './makeOpenApiRoute.mjs';
|
|
7
|
+
export { makeOpenApiPage } from './makeOpenApiPage.mjs';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function makeOpenApiPage(params) {
|
|
4
|
+
return /* html */ `
|
|
5
|
+
<!DOCTYPE html>
|
|
6
|
+
<html lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="utf-8" />
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
10
|
+
<meta name="description" content="SwaggerUI"/>
|
|
11
|
+
<title>${params.pageTitle}</title>
|
|
12
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@${params.swaggerUiVersion}/swagger-ui.css" />
|
|
13
|
+
<script src="https://unpkg.com/swagger-ui-dist@${params.swaggerUiVersion}/swagger-ui-bundle.js" crossorigin></script>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="swagger-ui"></div>
|
|
17
|
+
<script>
|
|
18
|
+
window.onload = () => {
|
|
19
|
+
window.ui = SwaggerUIBundle({
|
|
20
|
+
spec: ${params.openApiDocument},
|
|
21
|
+
dom_id: "#swagger-ui",
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.makeOpenApiPage = makeOpenApiPage;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function makeOpenApiPage(params) {
|
|
2
|
+
return /* html */ `
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
+
<meta name="description" content="SwaggerUI"/>
|
|
9
|
+
<title>${params.pageTitle}</title>
|
|
10
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@${params.swaggerUiVersion}/swagger-ui.css" />
|
|
11
|
+
<script src="https://unpkg.com/swagger-ui-dist@${params.swaggerUiVersion}/swagger-ui-bundle.js" crossorigin></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="swagger-ui"></div>
|
|
15
|
+
<script>
|
|
16
|
+
window.onload = () => {
|
|
17
|
+
window.ui = SwaggerUIBundle({
|
|
18
|
+
spec: ${params.openApiDocument},
|
|
19
|
+
dom_id: "#swagger-ui",
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { makeOpenApiPage };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../core/builders/index.cjs');
|
|
4
|
+
require('../../core/response/index.cjs');
|
|
5
|
+
var utils = require('@duplojs/utils');
|
|
6
|
+
var builder = require('../../core/builders/route/builder.cjs');
|
|
7
|
+
var contract = require('../../core/response/contract.cjs');
|
|
8
|
+
|
|
9
|
+
function makeOpenApiRoute(routePath, openApiPage) {
|
|
10
|
+
return builder.useRouteBuilder("GET", routePath)
|
|
11
|
+
.handler(contract.ResponseContract.ok("swaggerUi", utils.DP.string()), (__, { response }) => response("swaggerUi", openApiPage)
|
|
12
|
+
.setHeader("content-type", "text/html"));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.makeOpenApiRoute = makeOpenApiRoute;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ResponseContract } from "../../core/response";
|
|
2
|
+
import type { RoutePath } from "../../core/route";
|
|
3
|
+
import { DP } from "@duplojs/utils";
|
|
4
|
+
export declare function makeOpenApiRoute(routePath: RoutePath, openApiPage: string): import("../../core/route").Route<{
|
|
5
|
+
readonly method: "GET";
|
|
6
|
+
readonly hooks: readonly [];
|
|
7
|
+
readonly preflightSteps: readonly [];
|
|
8
|
+
readonly paths: readonly [`/${string}`];
|
|
9
|
+
readonly steps: readonly [import("../../core/steps").HandlerStep<{
|
|
10
|
+
readonly responseContract: NoInfer<ResponseContract.Contract<"200", "swaggerUi", DP.DataParserString<{
|
|
11
|
+
readonly errorMessage?: string | undefined;
|
|
12
|
+
readonly identifier?: string | undefined;
|
|
13
|
+
readonly coerce: boolean;
|
|
14
|
+
readonly checkers: readonly [];
|
|
15
|
+
}>>>;
|
|
16
|
+
theFunction(floor: {}, param: import("../../core/steps").HandlerStepFunctionParams<import("../../core/request").Request, import("../../core/response").PredictedResponse<"200", "swaggerUi", string>>): import("@duplojs/utils").MaybePromise<import("../../core/response").PredictedResponse<"200", "swaggerUi", string>>;
|
|
17
|
+
}>];
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../../core/builders/index.mjs';
|
|
2
|
+
import '../../core/response/index.mjs';
|
|
3
|
+
import { DP } from '@duplojs/utils';
|
|
4
|
+
import { useRouteBuilder } from '../../core/builders/route/builder.mjs';
|
|
5
|
+
import { ResponseContract } from '../../core/response/contract.mjs';
|
|
6
|
+
|
|
7
|
+
function makeOpenApiRoute(routePath, openApiPage) {
|
|
8
|
+
return useRouteBuilder("GET", routePath)
|
|
9
|
+
.handler(ResponseContract.ok("swaggerUi", DP.string()), (__, { response }) => response("swaggerUi", openApiPage)
|
|
10
|
+
.setHeader("content-type", "text/html"));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { makeOpenApiRoute };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var routeToOpenApi = require('./routeToOpenApi.cjs');
|
|
4
|
+
var utils = require('@duplojs/utils');
|
|
5
|
+
var makeOpenApiPage = require('./makeOpenApiPage.cjs');
|
|
6
|
+
var makeOpenApiRoute = require('./makeOpenApiRoute.cjs');
|
|
7
|
+
var promises = require('fs/promises');
|
|
8
|
+
|
|
9
|
+
function openApiGeneratorPlugin(pluginParams) {
|
|
10
|
+
return () => ({
|
|
11
|
+
name: "open-api-generator",
|
|
12
|
+
hooksHubLifeCycle: [
|
|
13
|
+
{
|
|
14
|
+
beforeServerBuildRoutes: async (hub) => {
|
|
15
|
+
const contextToJsonSchemaFactory = new Map();
|
|
16
|
+
const resultSchemaContext = new Map();
|
|
17
|
+
const routes = hub.aggregatesRoutes();
|
|
18
|
+
const openApiRoutes = utils.pipe(routes, utils.A.filter((route) => route.definition.method !== "OPTIONS"), utils.A.flatMap((route) => routeToOpenApi.routeToOpenApi(route, {
|
|
19
|
+
defaultExtractContract: hub.defaultExtractContract,
|
|
20
|
+
resultSchemaContext,
|
|
21
|
+
contextToJsonSchemaFactory,
|
|
22
|
+
})));
|
|
23
|
+
if (!utils.A.minElements(openApiRoutes, 1)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const paths = utils.pipe(openApiRoutes, utils.A.group((element, { output }) => output(element.path, element)), utils.O.entries, utils.A.filter((entry) => entry[1] !== undefined), utils.A.map(([path, value]) => utils.pipe(value, utils.A.group(({ method, path, ...rest }, { output }) => output(method, rest)), utils.O.entries, utils.A.filter((entry) => entry[1] !== undefined), utils.A.map(([method, value]) => utils.O.entry(method, utils.A.first(value))), utils.O.fromEntries, (value) => utils.O.entry(path, value))), utils.O.fromEntries);
|
|
27
|
+
const schemaComponents = utils.G.reduce(resultSchemaContext.values(), utils.G.reduceFrom({}), ({ lastValue, element, nextWithObject }) => nextWithObject(lastValue, element));
|
|
28
|
+
const securityScheme = utils.P.match(pluginParams.security)
|
|
29
|
+
.with({ type: "bearer" }, (security) => ({
|
|
30
|
+
type: "http",
|
|
31
|
+
scheme: "bearer",
|
|
32
|
+
bearerFormat: security.bearerFormat ?? "JWT",
|
|
33
|
+
}))
|
|
34
|
+
.with({ type: "basic" }, utils.justReturn({
|
|
35
|
+
type: "http",
|
|
36
|
+
scheme: "basic",
|
|
37
|
+
}))
|
|
38
|
+
.with({ type: "apiKey" }, (security) => ({
|
|
39
|
+
type: "apiKey",
|
|
40
|
+
name: security.paramName,
|
|
41
|
+
in: security.in,
|
|
42
|
+
}))
|
|
43
|
+
.otherwise(utils.justReturn(undefined));
|
|
44
|
+
const securitySchemeName = "auth";
|
|
45
|
+
const securitySchemes = securityScheme
|
|
46
|
+
? {
|
|
47
|
+
[securitySchemeName]: securityScheme,
|
|
48
|
+
}
|
|
49
|
+
: undefined;
|
|
50
|
+
const openApiDocument = {
|
|
51
|
+
openapi: "3.1.0",
|
|
52
|
+
info: {
|
|
53
|
+
title: pluginParams.title ?? "Swagger API",
|
|
54
|
+
version: pluginParams.version ?? "0.0.0",
|
|
55
|
+
summary: pluginParams.summary,
|
|
56
|
+
contact: pluginParams.contact,
|
|
57
|
+
license: pluginParams.license,
|
|
58
|
+
},
|
|
59
|
+
servers: pluginParams.servers,
|
|
60
|
+
paths,
|
|
61
|
+
components: {
|
|
62
|
+
schemas: schemaComponents,
|
|
63
|
+
securitySchemes,
|
|
64
|
+
},
|
|
65
|
+
security: pluginParams.security
|
|
66
|
+
? [
|
|
67
|
+
{
|
|
68
|
+
[securitySchemeName]: [],
|
|
69
|
+
},
|
|
70
|
+
]
|
|
71
|
+
: undefined,
|
|
72
|
+
};
|
|
73
|
+
const openApiDocumentString = JSON.stringify(openApiDocument, null, 2);
|
|
74
|
+
if (pluginParams.outputFilePath) {
|
|
75
|
+
await promises.writeFile(pluginParams.outputFilePath, openApiDocumentString);
|
|
76
|
+
}
|
|
77
|
+
const openApiPage = makeOpenApiPage.makeOpenApiPage({
|
|
78
|
+
openApiDocument: openApiDocumentString,
|
|
79
|
+
pageTitle: pluginParams.title ?? "Swagger API",
|
|
80
|
+
swaggerUiVersion: pluginParams.swaggerUiVersion ?? "5.31.0",
|
|
81
|
+
});
|
|
82
|
+
const openApiRoute = makeOpenApiRoute.makeOpenApiRoute(pluginParams.routePath, openApiPage);
|
|
83
|
+
return hub.register(openApiRoute);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
exports.openApiGeneratorPlugin = openApiGeneratorPlugin;
|