moonflower 0.9.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/.eslintrc.js +26 -0
- package/.prettierrc.js +7 -0
- package/README.md +383 -0
- package/cli/cli.ts +59 -0
- package/cli/entry.cjs +3 -0
- package/cli/prettyprint.ts +16 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +79 -0
- package/dist/cli/prettyprint.d.ts +4 -0
- package/dist/cli/prettyprint.d.ts.map +1 -0
- package/dist/cli/prettyprint.js +18 -0
- package/dist/src/errors/BaseHttpError.d.ts +13 -0
- package/dist/src/errors/BaseHttpError.d.ts.map +1 -0
- package/dist/src/errors/BaseHttpError.js +13 -0
- package/dist/src/errors/HttpErrorHandler.d.ts +3 -0
- package/dist/src/errors/HttpErrorHandler.d.ts.map +1 -0
- package/dist/src/errors/HttpErrorHandler.js +23 -0
- package/dist/src/errors/UserFacingErrors.d.ts +11 -0
- package/dist/src/errors/UserFacingErrors.d.ts.map +1 -0
- package/dist/src/errors/UserFacingErrors.js +23 -0
- package/dist/src/hooks/authentication/useAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useAuth.js +7 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useOptionalAuth.js +16 -0
- package/dist/src/hooks/useApiEndpoint.d.ts +8 -0
- package/dist/src/hooks/useApiEndpoint.d.ts.map +1 -0
- package/dist/src/hooks/useApiEndpoint.js +7 -0
- package/dist/src/hooks/useApiHeader/index.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/index.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/index.js +17 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts +3 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.js +6 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.js +22 -0
- package/dist/src/hooks/useCookieParams.d.ts +9 -0
- package/dist/src/hooks/useCookieParams.d.ts.map +1 -0
- package/dist/src/hooks/useCookieParams.js +50 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/index.js +17 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts +3 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.js +9 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.js +16 -0
- package/dist/src/hooks/useHeaderParams.d.ts +12 -0
- package/dist/src/hooks/useHeaderParams.d.ts.map +1 -0
- package/dist/src/hooks/useHeaderParams.js +52 -0
- package/dist/src/hooks/usePathParams.d.ts +22 -0
- package/dist/src/hooks/usePathParams.d.ts.map +1 -0
- package/dist/src/hooks/usePathParams.js +46 -0
- package/dist/src/hooks/useQueryParams.d.ts +9 -0
- package/dist/src/hooks/useQueryParams.d.ts.map +1 -0
- package/dist/src/hooks/useQueryParams.js +50 -0
- package/dist/src/hooks/useRequestBody.d.ts +9 -0
- package/dist/src/hooks/useRequestBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestBody.js +59 -0
- package/dist/src/hooks/useRequestRawBody.d.ts +7 -0
- package/dist/src/hooks/useRequestRawBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestRawBody.js +34 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +33 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts +18 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.js +192 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts +19 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.js +521 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts +4 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.js +246 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts +5 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.js +32 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts +2 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.js +400 -0
- package/dist/src/openapi/analyzerModule/types.d.ts +53 -0
- package/dist/src/openapi/analyzerModule/types.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/types.js +2 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts +8 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.js +33 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts +17 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.js +80 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts +6 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.js +31 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts +5 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.js +38 -0
- package/dist/src/openapi/discoveryModule/index.d.ts +3 -0
- package/dist/src/openapi/discoveryModule/index.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/index.js +18 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts +4 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.js +12 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts +10 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatePaths.js +116 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts +16 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatorModule.js +18 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts +36 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/getSchema.js +133 -0
- package/dist/src/openapi/generatorModule/index.d.ts +5 -0
- package/dist/src/openapi/generatorModule/index.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/index.js +20 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts +515 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.js +1119 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts +4 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts.map +1 -0
- package/dist/src/openapi/initOpenApiEngine.js +14 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts +67 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts.map +1 -0
- package/dist/src/openapi/manager/OpenApiManager.js +86 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts +4 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts.map +1 -0
- package/dist/src/openapi/router/OpenApiRouter.js +11 -0
- package/dist/src/openapi/types.d.ts +81 -0
- package/dist/src/openapi/types.d.ts.map +1 -0
- package/dist/src/openapi/types.js +2 -0
- package/dist/src/router/Router.d.ts +23 -0
- package/dist/src/router/Router.d.ts.map +1 -0
- package/dist/src/router/Router.js +81 -0
- package/dist/src/router/responseValueToJson.d.ts +2 -0
- package/dist/src/router/responseValueToJson.d.ts.map +1 -0
- package/dist/src/router/responseValueToJson.js +10 -0
- package/dist/src/setupTests.d.ts +1 -0
- package/dist/src/setupTests.d.ts.map +1 -0
- package/dist/src/setupTests.js +3 -0
- package/dist/src/test/TestAppRouter.d.ts +8 -0
- package/dist/src/test/TestAppRouter.d.ts.map +1 -0
- package/dist/src/test/TestAppRouter.js +58 -0
- package/dist/src/test/app.d.ts +3 -0
- package/dist/src/test/app.d.ts.map +1 -0
- package/dist/src/test/app.js +41 -0
- package/dist/src/utils/TypeUtils.d.ts +22 -0
- package/dist/src/utils/TypeUtils.d.ts.map +1 -0
- package/dist/src/utils/TypeUtils.js +2 -0
- package/dist/src/utils/fromZodSchema.d.ts +2 -0
- package/dist/src/utils/fromZodSchema.d.ts.map +1 -0
- package/dist/src/utils/fromZodSchema.js +6 -0
- package/dist/src/utils/loadTestData.d.ts +2 -0
- package/dist/src/utils/loadTestData.d.ts.map +1 -0
- package/dist/src/utils/loadTestData.js +39 -0
- package/dist/src/utils/mockContext.d.ts +20 -0
- package/dist/src/utils/mockContext.d.ts.map +1 -0
- package/dist/src/utils/mockContext.js +85 -0
- package/dist/src/utils/nameOf.d.ts +5 -0
- package/dist/src/utils/nameOf.d.ts.map +1 -0
- package/dist/src/utils/nameOf.js +7 -0
- package/dist/src/utils/object.d.ts +7 -0
- package/dist/src/utils/object.d.ts.map +1 -0
- package/dist/src/utils/object.js +21 -0
- package/dist/src/utils/printers.d.ts +6 -0
- package/dist/src/utils/printers.d.ts.map +1 -0
- package/dist/src/utils/printers.js +76 -0
- package/dist/src/utils/validationMessages.d.ts +18 -0
- package/dist/src/utils/validationMessages.d.ts.map +1 -0
- package/dist/src/utils/validationMessages.js +43 -0
- package/dist/src/validators/BuiltInValidators.d.ts +61 -0
- package/dist/src/validators/BuiltInValidators.d.ts.map +1 -0
- package/dist/src/validators/BuiltInValidators.js +66 -0
- package/dist/src/validators/InternalParamWrappers.d.ts +5 -0
- package/dist/src/validators/InternalParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/InternalParamWrappers.js +5 -0
- package/dist/src/validators/ParamWrappers.d.ts +11 -0
- package/dist/src/validators/ParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/ParamWrappers.js +9 -0
- package/dist/src/validators/types.d.ts +18 -0
- package/dist/src/validators/types.d.ts.map +1 -0
- package/dist/src/validators/types.js +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +59 -0
- package/src/errors/BaseHttpError.ts +16 -0
- package/src/errors/HttpErrorHandler.ts +20 -0
- package/src/errors/UserFacingErrors.ts +39 -0
- package/src/hooks/authentication/useAuth.ts +8 -0
- package/src/hooks/authentication/useOptionalAuth.ts +17 -0
- package/src/hooks/useApiEndpoint.spec.ts +11 -0
- package/src/hooks/useApiEndpoint.ts +10 -0
- package/src/hooks/useApiHeader/index.ts +1 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.data.ts +22 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.ts +34 -0
- package/src/hooks/useApiHeader/useApiHeader.ts +6 -0
- package/src/hooks/useCookieParams.spec.ts +174 -0
- package/src/hooks/useCookieParams.ts +73 -0
- package/src/hooks/useExposeApiModel/index.ts +1 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.ts +48 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.ts +388 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.ts +9 -0
- package/src/hooks/useHeaderParams.spec.ts +186 -0
- package/src/hooks/useHeaderParams.ts +83 -0
- package/src/hooks/usePathParams.spec.ts +161 -0
- package/src/hooks/usePathParams.ts +89 -0
- package/src/hooks/useQueryParams.spec.ts +224 -0
- package/src/hooks/useQueryParams.ts +73 -0
- package/src/hooks/useRequestBody.spec.ts +215 -0
- package/src/hooks/useRequestBody.ts +94 -0
- package/src/hooks/useRequestRawBody.spec.ts +154 -0
- package/src/hooks/useRequestRawBody.ts +56 -0
- package/src/index.ts +17 -0
- package/src/openapi/analyzerModule/analyzerModule.ts +228 -0
- package/src/openapi/analyzerModule/nodeParsers.ts +648 -0
- package/src/openapi/analyzerModule/parseEndpoint.ts +305 -0
- package/src/openapi/analyzerModule/parseExposedModels.ts +34 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +521 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +1043 -0
- package/src/openapi/analyzerModule/types.ts +72 -0
- package/src/openapi/discoveryModule/discoverImports/discoverImports.ts +43 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.spec.ts +36 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.ts +80 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.ts +42 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.ts +18 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.ts +39 -0
- package/src/openapi/discoveryModule/index.ts +2 -0
- package/src/openapi/generatorModule/generateComponentSchemas.ts +12 -0
- package/src/openapi/generatorModule/generatePaths.ts +138 -0
- package/src/openapi/generatorModule/generatorModule.ts +17 -0
- package/src/openapi/generatorModule/getSchema.ts +169 -0
- package/src/openapi/generatorModule/index.ts +4 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.data.ts +1119 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.ts +783 -0
- package/src/openapi/initOpenApiEngine.ts +20 -0
- package/src/openapi/manager/OpenApiManager.ts +153 -0
- package/src/openapi/router/OpenApiRouter.ts +11 -0
- package/src/openapi/types.ts +86 -0
- package/src/router/Router.ts +123 -0
- package/src/router/responseValueToJson.ts +6 -0
- package/src/setupTests.ts +3 -0
- package/src/test/TestAppRouter.ts +76 -0
- package/src/test/app.spec.ts +130 -0
- package/src/test/app.ts +43 -0
- package/src/utils/TypeUtils.ts +51 -0
- package/src/utils/loadTestData.ts +15 -0
- package/src/utils/mockContext.ts +86 -0
- package/src/utils/nameOf.ts +7 -0
- package/src/utils/object.spec.ts +27 -0
- package/src/utils/object.ts +17 -0
- package/src/utils/printers.spec.ts +103 -0
- package/src/utils/printers.ts +49 -0
- package/src/utils/validationMessages.ts +65 -0
- package/src/validators/BuiltInValidators.ts +64 -0
- package/src/validators/InternalParamWrappers.ts +14 -0
- package/src/validators/ParamWrappers.ts +22 -0
- package/src/validators/types.ts +35 -0
- package/tsconfig.build.json +15 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +16 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseEndpoint = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const nodeParsers_1 = require("./nodeParsers");
|
|
6
|
+
const parseEndpoint = (node, sourceFilePath) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const parsedEndpointMethod = node
|
|
9
|
+
.getFirstDescendantByKind(ts_morph_1.SyntaxKind.PropertyAccessExpression)
|
|
10
|
+
.getText()
|
|
11
|
+
.split('.')[1]
|
|
12
|
+
.toUpperCase();
|
|
13
|
+
const endpointMethod = parsedEndpointMethod === 'DEL' ? 'DELETE' : parsedEndpointMethod;
|
|
14
|
+
const endpointText = (_a = node.getFirstDescendantByKind(ts_morph_1.SyntaxKind.StringLiteral).getText()) !== null && _a !== void 0 ? _a : '';
|
|
15
|
+
const endpointPath = endpointText.substring(1, endpointText.length - 1);
|
|
16
|
+
const endpointData = {
|
|
17
|
+
method: endpointMethod,
|
|
18
|
+
path: endpointPath,
|
|
19
|
+
sourceFilePath,
|
|
20
|
+
requestPathParams: [],
|
|
21
|
+
requestQuery: [],
|
|
22
|
+
requestHeaders: [],
|
|
23
|
+
rawBody: undefined,
|
|
24
|
+
objectBody: [],
|
|
25
|
+
responses: [],
|
|
26
|
+
name: undefined,
|
|
27
|
+
summary: undefined,
|
|
28
|
+
description: undefined,
|
|
29
|
+
tags: undefined,
|
|
30
|
+
};
|
|
31
|
+
const warningData = [];
|
|
32
|
+
try {
|
|
33
|
+
const entries = parseApiDocumentation(node);
|
|
34
|
+
entries.forEach((param) => {
|
|
35
|
+
endpointData[param.identifier] = param.value;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
warningData.push({
|
|
40
|
+
segment: 'api',
|
|
41
|
+
error: err,
|
|
42
|
+
});
|
|
43
|
+
console.error('Error', err);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
endpointData.requestPathParams = parseRequestParams(node, endpointPath);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
warningData.push({
|
|
50
|
+
segment: 'path',
|
|
51
|
+
error: err,
|
|
52
|
+
});
|
|
53
|
+
console.error('Error', err);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
endpointData.requestQuery = parseRequestObjectInput(node, 'useQueryParams');
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
warningData.push({
|
|
60
|
+
segment: 'query',
|
|
61
|
+
error: err,
|
|
62
|
+
});
|
|
63
|
+
console.error('Error', err);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
endpointData.requestHeaders = parseRequestObjectInput(node, 'useHeaderParams');
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
warningData.push({
|
|
70
|
+
segment: 'headers',
|
|
71
|
+
error: err,
|
|
72
|
+
});
|
|
73
|
+
console.error('Error', err);
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const parsedBody = parseRequestRawBody(node);
|
|
77
|
+
if (parsedBody) {
|
|
78
|
+
endpointData.rawBody = parsedBody;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
warningData.push({
|
|
83
|
+
segment: 'rawBody',
|
|
84
|
+
error: err,
|
|
85
|
+
});
|
|
86
|
+
console.error('Error', err);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
endpointData.objectBody = parseRequestObjectInput(node, 'useRequestBody');
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
warningData.push({
|
|
93
|
+
segment: 'objectBody',
|
|
94
|
+
error: err,
|
|
95
|
+
});
|
|
96
|
+
console.error('Error', err);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
endpointData.responses = parseRequestResponse(node);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
warningData.push({
|
|
103
|
+
segment: 'response',
|
|
104
|
+
error: err,
|
|
105
|
+
});
|
|
106
|
+
console.error('Error', err);
|
|
107
|
+
}
|
|
108
|
+
return endpointData;
|
|
109
|
+
};
|
|
110
|
+
exports.parseEndpoint = parseEndpoint;
|
|
111
|
+
const getHookNode = (endpointNode, hookName) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const callExpressions = endpointNode.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
114
|
+
const matchingCallExpressions = callExpressions.filter((node) => {
|
|
115
|
+
var _a;
|
|
116
|
+
return ((_a = node.getFirstChildByKind(ts_morph_1.SyntaxKind.Identifier)) === null || _a === void 0 ? void 0 : _a.getText()) === hookName;
|
|
117
|
+
});
|
|
118
|
+
return (_a = matchingCallExpressions[0]) !== null && _a !== void 0 ? _a : null;
|
|
119
|
+
};
|
|
120
|
+
const parseApiDocumentation = (node) => {
|
|
121
|
+
const hookNode = getHookNode(node, 'useApiEndpoint');
|
|
122
|
+
if (!hookNode) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const paramNode = hookNode.getFirstChildByKind(ts_morph_1.SyntaxKind.SyntaxList);
|
|
126
|
+
const valueNode = (0, nodeParsers_1.findNodeImplementation)(paramNode.getLastChild());
|
|
127
|
+
if (!valueNode.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) {
|
|
128
|
+
throw new Error('Non-literal type used in useApiEndpoint');
|
|
129
|
+
}
|
|
130
|
+
const objectLiteral = valueNode.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
131
|
+
const values = (0, nodeParsers_1.getValuesOfObjectLiteral)(objectLiteral).filter((param) => param.value !== null);
|
|
132
|
+
return values;
|
|
133
|
+
};
|
|
134
|
+
const parseRequestParams = (node, endpointPath) => {
|
|
135
|
+
const hookNode = getHookNode(node, 'usePathParams');
|
|
136
|
+
if (!hookNode) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
const paramNode = hookNode.getFirstChildByKind(ts_morph_1.SyntaxKind.SyntaxList);
|
|
140
|
+
const valueNode = (0, nodeParsers_1.findNodeImplementation)(paramNode.getLastChild());
|
|
141
|
+
if (!valueNode.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) {
|
|
142
|
+
throw new Error('Non-literal type used in usePathParams');
|
|
143
|
+
}
|
|
144
|
+
const declaredParams = endpointPath
|
|
145
|
+
.split('/')
|
|
146
|
+
.filter((segment) => segment.startsWith(':'))
|
|
147
|
+
.map((segment) => ({
|
|
148
|
+
name: segment.substring(1).replace(/\?/, ''),
|
|
149
|
+
optional: segment.includes('?'),
|
|
150
|
+
}));
|
|
151
|
+
const objectLiteral = valueNode.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
152
|
+
return (0, nodeParsers_1.getShapeOfValidatorLiteral)(objectLiteral)
|
|
153
|
+
.filter((param) => param.shape !== null)
|
|
154
|
+
.map((param) => ({
|
|
155
|
+
identifier: param.identifier,
|
|
156
|
+
signature: param.shape,
|
|
157
|
+
optional: declaredParams.some((declared) => declared.name === param.identifier && declared.optional),
|
|
158
|
+
description: param.description,
|
|
159
|
+
errorMessage: param.errorMessage,
|
|
160
|
+
}));
|
|
161
|
+
};
|
|
162
|
+
const parseRequestRawBody = (node) => {
|
|
163
|
+
const hookNode = getHookNode(node, 'useRequestRawBody');
|
|
164
|
+
if (!hookNode) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const paramNode = hookNode.getFirstChildByKind(ts_morph_1.SyntaxKind.SyntaxList);
|
|
168
|
+
const valueNode = (0, nodeParsers_1.findNodeImplementation)(paramNode.getLastChild());
|
|
169
|
+
return {
|
|
170
|
+
signature: (0, nodeParsers_1.getValidatorPropertyShape)(valueNode),
|
|
171
|
+
optional: (0, nodeParsers_1.getValidatorPropertyOptionality)(valueNode),
|
|
172
|
+
description: (0, nodeParsers_1.getValidatorPropertyStringValue)(valueNode, 'description'),
|
|
173
|
+
errorMessage: (0, nodeParsers_1.getValidatorPropertyStringValue)(valueNode, 'errorMessage'),
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
const parseRequestObjectInput = (node, nodeName) => {
|
|
177
|
+
const hookNode = getHookNode(node, nodeName);
|
|
178
|
+
if (!hookNode) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
const paramNode = hookNode.getFirstChildByKind(ts_morph_1.SyntaxKind.SyntaxList);
|
|
182
|
+
const valueNode = (0, nodeParsers_1.findNodeImplementation)(paramNode.getLastChild());
|
|
183
|
+
if (!valueNode.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) {
|
|
184
|
+
throw new Error(`Non-literal type used in ${nodeName}`);
|
|
185
|
+
}
|
|
186
|
+
const objectLiteral = valueNode.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
187
|
+
return (0, nodeParsers_1.getShapeOfValidatorLiteral)(objectLiteral)
|
|
188
|
+
.filter((param) => param.shape !== null)
|
|
189
|
+
.map((param) => ({
|
|
190
|
+
identifier: param.identifier,
|
|
191
|
+
signature: param.shape,
|
|
192
|
+
optional: param.optional,
|
|
193
|
+
description: param.description,
|
|
194
|
+
errorMessage: param.errorMessage,
|
|
195
|
+
}));
|
|
196
|
+
};
|
|
197
|
+
const parseRequestResponse = (node) => {
|
|
198
|
+
const implementationNode = node
|
|
199
|
+
.getFirstChildByKind(ts_morph_1.SyntaxKind.CallExpression)
|
|
200
|
+
.getFirstChildByKind(ts_morph_1.SyntaxKind.SyntaxList)
|
|
201
|
+
.getFirstChildByKind(ts_morph_1.SyntaxKind.ArrowFunction);
|
|
202
|
+
const returnType = implementationNode.getReturnType();
|
|
203
|
+
const actualType = (() => {
|
|
204
|
+
if (returnType.getText().startsWith('Promise')) {
|
|
205
|
+
return returnType.getTypeArguments()[0];
|
|
206
|
+
}
|
|
207
|
+
return returnType;
|
|
208
|
+
})();
|
|
209
|
+
const responseType = (0, nodeParsers_1.getProperTypeShape)(actualType, node);
|
|
210
|
+
if (typeof responseType === 'string') {
|
|
211
|
+
return [
|
|
212
|
+
{
|
|
213
|
+
status: responseType === 'void' || responseType === 'null' ? 204 : 200,
|
|
214
|
+
signature: responseType,
|
|
215
|
+
description: '',
|
|
216
|
+
errorMessage: '',
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
if (responseType[0].role === 'union') {
|
|
221
|
+
if (typeof responseType[0].shape === 'string') {
|
|
222
|
+
return [
|
|
223
|
+
{
|
|
224
|
+
status: responseType[0].shape === 'void' || responseType[0].shape === 'null' ? 204 : 200,
|
|
225
|
+
signature: responseType[0].shape,
|
|
226
|
+
description: '',
|
|
227
|
+
errorMessage: '',
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
return responseType[0].shape.map((unionEntry) => ({
|
|
232
|
+
status: unionEntry.shape === 'void' || unionEntry.shape === 'null' ? 204 : 200,
|
|
233
|
+
signature: unionEntry.shape,
|
|
234
|
+
description: '',
|
|
235
|
+
errorMessage: '',
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
return [
|
|
239
|
+
{
|
|
240
|
+
status: 200,
|
|
241
|
+
signature: responseType,
|
|
242
|
+
description: '',
|
|
243
|
+
errorMessage: '',
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Node, ts } from 'ts-morph';
|
|
2
|
+
import { ExposedModelData } from '../types';
|
|
3
|
+
export declare const parseExposedModel: (node: Node<ts.Node>) => ExposedModelData;
|
|
4
|
+
export declare const parseNamedExposedModels: (node: Node<ts.Node>) => ExposedModelData[];
|
|
5
|
+
//# sourceMappingURL=parseExposedModels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseExposedModels.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/parseExposedModels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAI3C,eAAO,MAAM,iBAAiB,SAAU,KAAK,OAAO,CAAC,KAAG,gBAevD,CAAA;AAED,eAAO,MAAM,uBAAuB,SAAU,KAAK,OAAO,CAAC,KAAG,gBAAgB,EAS7E,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseNamedExposedModels = exports.parseExposedModel = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const nodeParsers_1 = require("./nodeParsers");
|
|
6
|
+
const parseExposedModel = (node) => {
|
|
7
|
+
if (node.isKind(ts_morph_1.SyntaxKind.TypeReference) || node.isKind(ts_morph_1.SyntaxKind.TypeQuery)) {
|
|
8
|
+
const identifierNode = node.getFirstChildByKind(ts_morph_1.SyntaxKind.Identifier);
|
|
9
|
+
const modelName = identifierNode.getText();
|
|
10
|
+
const modelShape = (0, nodeParsers_1.getProperTypeShape)(node.getType(), node, []);
|
|
11
|
+
return {
|
|
12
|
+
name: modelName,
|
|
13
|
+
shape: modelShape,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
name: '',
|
|
18
|
+
shape: '',
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.parseExposedModel = parseExposedModel;
|
|
22
|
+
const parseNamedExposedModels = (node) => {
|
|
23
|
+
if (node.isKind(ts_morph_1.SyntaxKind.TypeLiteral)) {
|
|
24
|
+
const shape = (0, nodeParsers_1.getProperTypeShape)(node.getType(), node, []);
|
|
25
|
+
return shape.map((property) => ({
|
|
26
|
+
name: property.identifier,
|
|
27
|
+
shape: property.shape,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
};
|
|
32
|
+
exports.parseNamedExposedModels = parseNamedExposedModels;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiAnalyzer.spec.data.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const useApiEndpoint_1 = require("../../../hooks/useApiEndpoint");
|
|
4
|
+
const useExposeApiModel_1 = require("../../../hooks/useExposeApiModel/useExposeApiModel");
|
|
5
|
+
const useHeaderParams_1 = require("../../../hooks/useHeaderParams");
|
|
6
|
+
const usePathParams_1 = require("../../../hooks/usePathParams");
|
|
7
|
+
const useQueryParams_1 = require("../../../hooks/useQueryParams");
|
|
8
|
+
const useRequestBody_1 = require("../../../hooks/useRequestBody");
|
|
9
|
+
const useRequestRawBody_1 = require("../../../hooks/useRequestRawBody");
|
|
10
|
+
const Router_1 = require("../../../router/Router");
|
|
11
|
+
const BuiltInValidators_1 = require("../../../validators/BuiltInValidators");
|
|
12
|
+
const ParamWrappers_1 = require("../../../validators/ParamWrappers");
|
|
13
|
+
const router = new Router_1.Router();
|
|
14
|
+
router.get('/test/908c3e74-cf67-4ec7-a281-66a79f95d44d', () => {
|
|
15
|
+
(0, useApiEndpoint_1.useApiEndpoint)({
|
|
16
|
+
name: 'Test endpoint name',
|
|
17
|
+
summary: 'Test endpoint summary',
|
|
18
|
+
description: 'Test endpoint description',
|
|
19
|
+
tags: ['one', 'two', 'three'],
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
router.get('/test/f2473a55-0ac6-46a0-b3c6-aae060dbe0ab', () => {
|
|
23
|
+
const firstTag = 'one';
|
|
24
|
+
const secondTag = 'two';
|
|
25
|
+
(0, useApiEndpoint_1.useApiEndpoint)({
|
|
26
|
+
tags: [firstTag, secondTag],
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
router.get('/test/b504a196-d31d-40a4-a901-38a0f34f6ea7', () => {
|
|
30
|
+
const tagContainer = {
|
|
31
|
+
firstTag: 'one',
|
|
32
|
+
secondTag: 'two',
|
|
33
|
+
};
|
|
34
|
+
(0, useApiEndpoint_1.useApiEndpoint)({
|
|
35
|
+
tags: [tagContainer.firstTag, tagContainer.secondTag],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
router.get('/test/bf6147f2-a1dc-4cc2-8327-e6f041f828bf/:firstParam/:secondParam/:optionalParam?', (ctx) => {
|
|
39
|
+
(0, usePathParams_1.usePathParams)(ctx, {
|
|
40
|
+
firstParam: (0, ParamWrappers_1.PathParam)({
|
|
41
|
+
parse: (v) => String(v),
|
|
42
|
+
}),
|
|
43
|
+
secondParam: (0, ParamWrappers_1.PathParam)({
|
|
44
|
+
parse: (v) => v === '1',
|
|
45
|
+
}),
|
|
46
|
+
optionalParam: (0, ParamWrappers_1.PathParam)({
|
|
47
|
+
parse: (v) => Number(v),
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
router.get('/test/ef25ef5e-0f8f-4732-bf59-8825f94a5287/:firstParam/:secondParam/:optionalParam?', (ctx) => {
|
|
52
|
+
(0, usePathParams_1.usePathParams)(ctx, {
|
|
53
|
+
firstParam: BuiltInValidators_1.StringValidator,
|
|
54
|
+
secondParam: (0, ParamWrappers_1.PathParam)(BuiltInValidators_1.BooleanValidator),
|
|
55
|
+
optionalParam: BuiltInValidators_1.NumberValidator,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
router.get('/test/5ab5dd0d-b241-4378-bea1-a2dd696d699a/:firstParam/:secondParam', (ctx) => {
|
|
59
|
+
(0, usePathParams_1.usePathParams)(ctx, {
|
|
60
|
+
firstParam: (0, ParamWrappers_1.PathParam)({
|
|
61
|
+
parse: (v) => JSON.parse(String(v)),
|
|
62
|
+
}),
|
|
63
|
+
secondParam: (0, ParamWrappers_1.PathParam)({
|
|
64
|
+
parse: (v) => JSON.parse(String(v)),
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
router.get('/test/209df2a1-55f9-4859-bc31-3277547c7d88/:firstParam/:secondParam', (ctx) => {
|
|
69
|
+
(0, usePathParams_1.usePathParams)(ctx, {
|
|
70
|
+
firstParam: (0, ParamWrappers_1.PathParam)({
|
|
71
|
+
parse: (v) => JSON.parse(String(v)),
|
|
72
|
+
}),
|
|
73
|
+
secondParam: (0, ParamWrappers_1.PathParam)({
|
|
74
|
+
parse: (v) => JSON.parse(String(v)),
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
router.get('/test/89d961f1-7d36-4271-8bd3-665ee0992590/:firstParam/:secondParam', (ctx) => {
|
|
79
|
+
(0, usePathParams_1.usePathParams)(ctx, {
|
|
80
|
+
firstParam: (0, ParamWrappers_1.PathParam)({
|
|
81
|
+
parse: (v) => JSON.parse(String(v)),
|
|
82
|
+
}),
|
|
83
|
+
secondParam: (0, ParamWrappers_1.PathParam)({
|
|
84
|
+
parse: (v) => JSON.parse(String(v)),
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
router.get('/test/f89310d9-25ac-4005-93e4-614179d3bbd4', (ctx) => {
|
|
89
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
90
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)({
|
|
91
|
+
parse: (v) => String(v),
|
|
92
|
+
}),
|
|
93
|
+
secondParam: (0, ParamWrappers_1.OptionalParam)({
|
|
94
|
+
parse: (v) => v === '1',
|
|
95
|
+
}),
|
|
96
|
+
thirdParam: (0, ParamWrappers_1.OptionalParam)({
|
|
97
|
+
parse: (v) => Number(v),
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
router.post('/test/7c51de80-1ff1-4511-b0d3-8a75c296c507', (ctx) => {
|
|
102
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
103
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
104
|
+
parse: (v) => v,
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
router.get('/test/2c5483d3-7b21-421a-92a8-34e54a008b82', (ctx) => {
|
|
109
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
110
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
111
|
+
parse: (v) => v,
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
router.get('/test/724a56ef-32f9-4c59-b22c-60bd33e45242', (ctx) => {
|
|
116
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
117
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
118
|
+
parse: (v) => v,
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
router.get('/test/2b9a53fa-4418-4303-9202-3f8e46f73aed', (ctx) => {
|
|
123
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
124
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
125
|
+
parse: (v) => String(v),
|
|
126
|
+
description: 'Test description',
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
router.get('/test/685ac7fb-18ee-4ace-b68e-a6ee354ad4db', (ctx) => {
|
|
131
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
132
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
133
|
+
parse: (v) => String(v),
|
|
134
|
+
errorMessage: 'Test error message',
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
router.get('/test/d8b07b26-5202-434c-9ff6-3fe792dad40f', (ctx) => {
|
|
139
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
140
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
141
|
+
parse: (v) => JSON.parse(String(v)),
|
|
142
|
+
}),
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
router.get('/test/03c247cb-96c0-4748-bb6a-9569c7bdb436', (ctx) => {
|
|
146
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
147
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)({
|
|
148
|
+
parse: (v) => String(v),
|
|
149
|
+
}),
|
|
150
|
+
secondParam: (0, ParamWrappers_1.OptionalParam)({
|
|
151
|
+
parse: (v) => v === '1',
|
|
152
|
+
}),
|
|
153
|
+
thirdParam: (0, ParamWrappers_1.OptionalParam)({
|
|
154
|
+
parse: (v) => Number(v),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
router.get('/test/e563aa37-803e-4b79-a3e8-af0d01d024ae', (ctx) => {
|
|
159
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
160
|
+
'header-with-dashes': (0, ParamWrappers_1.RequiredParam)({
|
|
161
|
+
parse: (v) => String(v),
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
router.get('/test/a3e79aaa-2d0f-4481-9226-a10904e76354', (ctx) => {
|
|
166
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
167
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
168
|
+
parse: (v) => String(v),
|
|
169
|
+
description: 'Test description',
|
|
170
|
+
}),
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
router.get('/test/219c5c4e-1558-4d0b-85be-9753dfc14083', (ctx) => {
|
|
174
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
175
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
176
|
+
parse: (v) => String(v),
|
|
177
|
+
errorMessage: 'Test error message',
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
router.get('/test/1ea8bc2f-3f66-4409-ba4a-289f33bcc8fd', (ctx) => {
|
|
182
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
183
|
+
foo: BuiltInValidators_1.StringValidator,
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
router.get('/test/c679c01e-a403-4a5c-8097-3abbe891a625', (ctx) => {
|
|
187
|
+
(0, useHeaderParams_1.useHeaderParams)(ctx, {
|
|
188
|
+
foo: (0, ParamWrappers_1.RequiredParam)(BuiltInValidators_1.StringValidator),
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
router.get('/test/6040cd01-a0c6-4b70-9901-b647f19b19a7', (ctx) => {
|
|
192
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.RequiredParam)({
|
|
193
|
+
parse: (v) => JSON.parse(String(v)),
|
|
194
|
+
}));
|
|
195
|
+
});
|
|
196
|
+
router.get('/test/f3754325-6d9c-42b6-becf-4a9e72bd2c4e', (ctx) => {
|
|
197
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.RequiredParam)({
|
|
198
|
+
parse: (v) => JSON.parse(String(v)),
|
|
199
|
+
}));
|
|
200
|
+
});
|
|
201
|
+
router.get('/test/1ab973ff-9937-4e2d-b432-ff43a9df42cb', (ctx) => {
|
|
202
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.OptionalParam)({
|
|
203
|
+
parse: (v) => JSON.parse(String(v)),
|
|
204
|
+
}));
|
|
205
|
+
});
|
|
206
|
+
router.get('/test/f74f6003-2aba-4f8c-855e-c0149f4217b7', (ctx) => {
|
|
207
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.OptionalParam)(BuiltInValidators_1.BooleanValidator));
|
|
208
|
+
});
|
|
209
|
+
router.get('/test/54768e53-4094-4e2e-96bf-8891235f264b', (ctx) => {
|
|
210
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.RequiredParam)({
|
|
211
|
+
parse: (v) => String(v),
|
|
212
|
+
description: 'Test description',
|
|
213
|
+
errorMessage: 'Test error message',
|
|
214
|
+
}));
|
|
215
|
+
});
|
|
216
|
+
router.get('/test/87a1470c-3fec-492a-bc4c-ff35fc95524a', (ctx) => {
|
|
217
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.RequiredParam)({
|
|
218
|
+
parse: (v) => String(v),
|
|
219
|
+
description: 'Test description',
|
|
220
|
+
errorMessage: 'Test error message',
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
router.get('/test/32f51057-743a-4c37-9647-476f9a8581f3', (ctx) => {
|
|
224
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, BuiltInValidators_1.StringValidator);
|
|
225
|
+
});
|
|
226
|
+
router.get('/test/2fbc419b-2f1c-4782-9113-ef4125dd813b', (ctx) => {
|
|
227
|
+
(0, useRequestRawBody_1.useRequestRawBody)(ctx, (0, ParamWrappers_1.OptionalParam)(BuiltInValidators_1.StringValidator));
|
|
228
|
+
});
|
|
229
|
+
router.get('/test/e8e5496b-11a0-41e3-a68d-f03d524e413c', (ctx) => {
|
|
230
|
+
(0, useRequestBody_1.useRequestBody)(ctx, {
|
|
231
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)({
|
|
232
|
+
parse: (v) => String(v),
|
|
233
|
+
}),
|
|
234
|
+
secondParam: (0, ParamWrappers_1.OptionalParam)({
|
|
235
|
+
parse: (v) => v === '1',
|
|
236
|
+
}),
|
|
237
|
+
thirdParam: (0, ParamWrappers_1.OptionalParam)({
|
|
238
|
+
parse: (v) => Number(v),
|
|
239
|
+
}),
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
router.get('/test/c9a2301c-babd-4512-935c-b9664803e720', (ctx) => {
|
|
243
|
+
(0, useRequestBody_1.useRequestBody)(ctx, {
|
|
244
|
+
firstParam: (0, ParamWrappers_1.OptionalParam)(BuiltInValidators_1.StringValidator),
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
router.get('/test/b3b9aec9-f58e-4c4b-8cf6-ca2fe11c5331', (ctx) => {
|
|
248
|
+
(0, useRequestBody_1.useRequestBody)(ctx, {
|
|
249
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)(BuiltInValidators_1.BigIntValidator),
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
router.get('/test/e1bedf55-6d3a-4c01-9c66-6ec74cc66c3b', () => {
|
|
253
|
+
return 'Hello world';
|
|
254
|
+
});
|
|
255
|
+
router.get('/test/78ad5fba-f4e2-4924-b28a-23e39dd146f7', () => {
|
|
256
|
+
const random = Math.random();
|
|
257
|
+
if (random < 0.33) {
|
|
258
|
+
return 100;
|
|
259
|
+
}
|
|
260
|
+
else if (random < 0.67) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return 'Hello world';
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
router.get('/test/c542cb10-538c-44eb-8d13-5111e273ead0', () => {
|
|
268
|
+
return {
|
|
269
|
+
foo: 'test',
|
|
270
|
+
bar: 12,
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
router.get('/test/03888127-6b97-42df-b429-87a6588ab2a4', () => {
|
|
274
|
+
return {};
|
|
275
|
+
});
|
|
276
|
+
router.get('/test/b73347dc-c16f-4272-95b4-bf1716bf9c14', () => {
|
|
277
|
+
return {
|
|
278
|
+
foo: 123,
|
|
279
|
+
};
|
|
280
|
+
});
|
|
281
|
+
router.get('/test/666b9ed1-62db-447a-80a7-8f35ec50ab02', async () => {
|
|
282
|
+
return {
|
|
283
|
+
foo: 123,
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
router.get('/test/97bb5db8-1871-4c1d-998e-a724c04c5741', (ctx) => {
|
|
287
|
+
const query = (0, useQueryParams_1.useQueryParams)(ctx, {
|
|
288
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)({
|
|
289
|
+
parse: (v) => String(v),
|
|
290
|
+
}),
|
|
291
|
+
secondParam: (0, ParamWrappers_1.OptionalParam)({
|
|
292
|
+
parse: (v) => v === '1',
|
|
293
|
+
}),
|
|
294
|
+
thirdParam: (0, ParamWrappers_1.OptionalParam)({
|
|
295
|
+
parse: (v) => Number(v),
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
return {
|
|
299
|
+
foo: query.firstParam,
|
|
300
|
+
bar: query.secondParam,
|
|
301
|
+
baz: query.thirdParam,
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
router.get('/test/4188ebf2-eae6-4994-8732-c7f43d4da861', (ctx) => {
|
|
305
|
+
const query = (0, useQueryParams_1.useQueryParams)(ctx, {
|
|
306
|
+
firstParam: (0, ParamWrappers_1.RequiredParam)({
|
|
307
|
+
parse: (v) => String(v),
|
|
308
|
+
}),
|
|
309
|
+
secondParam: (0, ParamWrappers_1.OptionalParam)({
|
|
310
|
+
parse: (v) => v === '1',
|
|
311
|
+
}),
|
|
312
|
+
thirdParam: (0, ParamWrappers_1.OptionalParam)({
|
|
313
|
+
parse: (v) => Number(v),
|
|
314
|
+
}),
|
|
315
|
+
});
|
|
316
|
+
if (Math.random() > 0.5) {
|
|
317
|
+
return {
|
|
318
|
+
test: 'value',
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
foo: query.firstParam,
|
|
323
|
+
bar: query.secondParam,
|
|
324
|
+
baz: query.thirdParam,
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
router.get('/test/32f18a25-2408-46cf-9519-f9a8d855bf84', () => {
|
|
328
|
+
return {};
|
|
329
|
+
});
|
|
330
|
+
router.get('/test/196f2937-e369-435f-b239-62eaacaa6fbd', () => {
|
|
331
|
+
});
|
|
332
|
+
router.post('/test/33a0f888-396e-4c4d-b1d9-4cf6600ab88d', () => {
|
|
333
|
+
return {};
|
|
334
|
+
});
|
|
335
|
+
router.post('/test/e3659429-1a05-4590-a5a6-dc80a30878e6', () => {
|
|
336
|
+
return ['foo', 'bar'];
|
|
337
|
+
});
|
|
338
|
+
router.get('/test/9470a1f7-1781-43ea-aa32-4d7d71eddf4f', () => {
|
|
339
|
+
return 0;
|
|
340
|
+
});
|
|
341
|
+
router.get('/test/be7205a2-3bc3-490e-be25-988d7ab65f20', () => {
|
|
342
|
+
return 0;
|
|
343
|
+
});
|
|
344
|
+
router.get('/test/006b4d53-15a4-405e-b94d-1fa3abbd19aa', () => {
|
|
345
|
+
return '';
|
|
346
|
+
});
|
|
347
|
+
router.get('/test/a8f4e5f7-ed58-4de6-8877-b14bf14ae176', () => {
|
|
348
|
+
return '';
|
|
349
|
+
});
|
|
350
|
+
router.get('/test/b9fae12a-be41-4aef-9250-f6d67cd0aee6', () => {
|
|
351
|
+
return {};
|
|
352
|
+
});
|
|
353
|
+
router.get('/test/dba70b93-8e8f-4731-8869-285831d18fcb', () => {
|
|
354
|
+
return {};
|
|
355
|
+
});
|
|
356
|
+
router.get('/test/79207cfa-916a-4474-9d98-45196d2451b5', () => {
|
|
357
|
+
return {};
|
|
358
|
+
});
|
|
359
|
+
router.get('/test/19207cfa-916a-4474-9d98-45196d2451b6', () => {
|
|
360
|
+
return { foo: BigInt(2) };
|
|
361
|
+
});
|
|
362
|
+
router.get('/test/66a075bc-c9d4-4622-8c04-e0a982a19fb0', (ctx) => {
|
|
363
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
364
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
365
|
+
parse: (v) => JSON.parse(String(v)),
|
|
366
|
+
}),
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
router.get('/test/39669151-c529-4bcd-86a5-a10de7834104/:foo', (ctx) => {
|
|
370
|
+
const { foo } = (0, usePathParams_1.usePathParams)(ctx, {
|
|
371
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
372
|
+
parse: (v) => String(v),
|
|
373
|
+
}),
|
|
374
|
+
});
|
|
375
|
+
foo;
|
|
376
|
+
});
|
|
377
|
+
(0, useExposeApiModel_1.useExposeApiModel)();
|
|
378
|
+
(0, useExposeApiModel_1.useExposeNamedApiModels)();
|
|
379
|
+
router.get('/test/e917e982-b5ce-4a8f-804e-13466e7a00a2', (ctx) => {
|
|
380
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
381
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
382
|
+
parse: (v) => JSON.parse(String(v)),
|
|
383
|
+
}),
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
router.get('/test/af22e5ff-7cbf-4aa3-8ea9-fd538a747c01', (ctx) => {
|
|
387
|
+
(0, useQueryParams_1.useQueryParams)(ctx, {
|
|
388
|
+
foo: (0, ParamWrappers_1.RequiredParam)({
|
|
389
|
+
parse: (v) => JSON.parse(String(v)),
|
|
390
|
+
}),
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
router.get('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
394
|
+
});
|
|
395
|
+
router.post('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
396
|
+
});
|
|
397
|
+
router.patch('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
398
|
+
});
|
|
399
|
+
router.delete('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
400
|
+
});
|