moonflower 0.9.3 → 0.10.1
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/src/hooks/useReturnValue.d.ts +7 -0
- package/dist/src/hooks/useReturnValue.d.ts.map +1 -0
- package/dist/src/hooks/useReturnValue.js +12 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts.map +1 -1
- package/dist/src/openapi/analyzerModule/nodeParsers.js +9 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.js +50 -6
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.js +27 -0
- package/dist/src/openapi/analyzerModule/types.d.ts +6 -1
- package/dist/src/openapi/analyzerModule/types.d.ts.map +1 -1
- package/dist/src/openapi/generatorModule/generatePaths.d.ts.map +1 -1
- package/dist/src/openapi/generatorModule/generatePaths.js +5 -6
- package/dist/src/openapi/generatorModule/getSchema.d.ts.map +1 -1
- package/dist/src/openapi/generatorModule/getSchema.js +7 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts.map +1 -1
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.js +27 -20
- package/dist/src/openapi/types.d.ts +5 -6
- package/dist/src/openapi/types.d.ts.map +1 -1
- package/dist/src/router/Router.d.ts.map +1 -1
- package/dist/src/router/Router.js +19 -13
- package/dist/src/router/parseEndpointReturnValue.d.ts +8 -0
- package/dist/src/router/parseEndpointReturnValue.d.ts.map +1 -0
- package/dist/src/router/parseEndpointReturnValue.js +33 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/hooks/useReturnValue.spec.ts +16 -0
- package/src/hooks/useReturnValue.ts +12 -0
- package/src/openapi/analyzerModule/nodeParsers.ts +10 -0
- package/src/openapi/analyzerModule/parseEndpoint.ts +59 -6
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +31 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +31 -0
- package/src/openapi/analyzerModule/types.ts +7 -0
- package/src/openapi/generatorModule/generatePaths.ts +5 -2
- package/src/openapi/generatorModule/getSchema.ts +8 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.data.ts +27 -20
- package/src/openapi/generatorModule/test/openApiGenerator.spec.ts +191 -0
- package/src/openapi/types.ts +5 -3
- package/src/router/Router.ts +19 -13
- package/src/router/parseEndpointReturnValue.spec.ts +35 -0
- package/src/router/parseEndpointReturnValue.ts +31 -0
- package/src/router/responseValueToJson.ts +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReturnValue.d.ts","sourceRoot":"","sources":["../../../src/hooks/useReturnValue.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,iDACnB,CAAC,UACA,CAAC,eACI,CAAC;;;;;CAQd,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useReturnValue = void 0;
|
|
4
|
+
const useReturnValue = (value, status, contentType) => {
|
|
5
|
+
return {
|
|
6
|
+
_isUseReturnValue: true,
|
|
7
|
+
status,
|
|
8
|
+
value,
|
|
9
|
+
contentType,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.useReturnValue = useReturnValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeParsers.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/nodeParsers.ts"],"names":[],"mappings":"AACA,OAAO,EACN,IAAI,EACJ,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAE3B,EAAE,EACF,IAAI,EACJ,iBAAiB,EACjB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAA;AAEzE,eAAO,MAAM,sBAAsB,SAAU,IAAI,KAAG,IAyBnD,CAAA;AAED,eAAO,MAAM,+BAA+B,SAExC,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,wBAAwB,GACxB,2BAA2B,KAC5B,IAYF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,iBAAiB,KAAG,WAAW,CAAC,OAAO,CAOlF,CAAA;AAED,eAAO,MAAM,qBAAqB,oBAAqB,IAAI,KAAG,WAAW,CAAC,OAAO,CAkIhF,CAAA;AAED,eAAO,MAAM,0BAA0B,sBACnB,KAAK,GAAG,uBAAuB,CAAC,KACjD,CAAC,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EA8BnE,CAAA;AAED,eAAO,MAAM,yBAAyB,qBAAsB,IAAI,KAAG,WAAW,CAAC,OAAO,CAoFrF,CAAA;AAED,eAAO,MAAM,+BAA+B,SAAU,IAAI,KAAG,OA4B5D,CAAA;AAED,eAAO,MAAM,+BAA+B,oBAC1B,IAAI,QACf,aAAa,GAAG,cAAc,KAClC,MAuDF,CAAA;AAWD,eAAO,MAAM,kBAAkB,kBACf,IAAI,cACP,IAAI,UACT,IAAI,EAAE,KACX,WAAW,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"nodeParsers.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/nodeParsers.ts"],"names":[],"mappings":"AACA,OAAO,EACN,IAAI,EACJ,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAE3B,EAAE,EACF,IAAI,EACJ,iBAAiB,EACjB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAA;AAEzE,eAAO,MAAM,sBAAsB,SAAU,IAAI,KAAG,IAyBnD,CAAA;AAED,eAAO,MAAM,+BAA+B,SAExC,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,wBAAwB,GACxB,2BAA2B,KAC5B,IAYF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,iBAAiB,KAAG,WAAW,CAAC,OAAO,CAOlF,CAAA;AAED,eAAO,MAAM,qBAAqB,oBAAqB,IAAI,KAAG,WAAW,CAAC,OAAO,CAkIhF,CAAA;AAED,eAAO,MAAM,0BAA0B,sBACnB,KAAK,GAAG,uBAAuB,CAAC,KACjD,CAAC,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EA8BnE,CAAA;AAED,eAAO,MAAM,yBAAyB,qBAAsB,IAAI,KAAG,WAAW,CAAC,OAAO,CAoFrF,CAAA;AAED,eAAO,MAAM,+BAA+B,SAAU,IAAI,KAAG,OA4B5D,CAAA;AAED,eAAO,MAAM,+BAA+B,oBAC1B,IAAI,QACf,aAAa,GAAG,cAAc,KAClC,MAuDF,CAAA;AAWD,eAAO,MAAM,kBAAkB,kBACf,IAAI,cACP,IAAI,UACT,IAAI,EAAE,KACX,WAAW,CAAC,OAAO,CAiMrB,CAAA;AAiBD,eAAO,MAAM,wBAAwB,sBAAuB,KAAK,GAAG,uBAAuB,CAAC;;;GAmB3F,CAAA"}
|
|
@@ -406,6 +406,15 @@ const getProperTypeShape = (typeOrPromise, atLocation, stack = []) => {
|
|
|
406
406
|
},
|
|
407
407
|
];
|
|
408
408
|
}
|
|
409
|
+
if (type.isObject() && type.getText() === 'Buffer') {
|
|
410
|
+
return [
|
|
411
|
+
{
|
|
412
|
+
role: 'buffer',
|
|
413
|
+
shape: 'buffer',
|
|
414
|
+
optional: false,
|
|
415
|
+
},
|
|
416
|
+
];
|
|
417
|
+
}
|
|
409
418
|
if (type.isObject() && type.getProperties().length === 0) {
|
|
410
419
|
const targetType = type.getAliasTypeArguments()[1];
|
|
411
420
|
return [
|
|
@@ -207,10 +207,44 @@ const parseRequestResponse = (node) => {
|
|
|
207
207
|
return returnType;
|
|
208
208
|
})();
|
|
209
209
|
const responseType = (0, nodeParsers_1.getProperTypeShape)(actualType, node);
|
|
210
|
+
return parseResponseTypes(responseType);
|
|
211
|
+
};
|
|
212
|
+
const parseResponseTypes = (responseType) => {
|
|
210
213
|
if (typeof responseType === 'string') {
|
|
211
214
|
return [
|
|
212
215
|
{
|
|
213
216
|
status: responseType === 'void' || responseType === 'null' ? 204 : 200,
|
|
217
|
+
contentType: 'text/plain',
|
|
218
|
+
signature: responseType,
|
|
219
|
+
description: '',
|
|
220
|
+
errorMessage: '',
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
if (responseType[0].role === 'union_entry' || responseType[0].role === 'literal_string') {
|
|
225
|
+
return parseResponseTypes(responseType[0].shape);
|
|
226
|
+
}
|
|
227
|
+
if (responseType[0].role === 'property' && responseType[0].identifier === '_isUseReturnValue') {
|
|
228
|
+
const status = (() => {
|
|
229
|
+
var _a;
|
|
230
|
+
const property = (_a = responseType.find((response) => response.role === 'property' && response.identifier === 'status')) === null || _a === void 0 ? void 0 : _a.shape;
|
|
231
|
+
if (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {
|
|
232
|
+
throw new Error('Invalid useReturnValue hook');
|
|
233
|
+
}
|
|
234
|
+
return parseInt(property[0].shape);
|
|
235
|
+
})();
|
|
236
|
+
const contentType = (() => {
|
|
237
|
+
var _a;
|
|
238
|
+
const property = (_a = responseType.find((response) => response.role === 'property' && response.identifier === 'contentType')) === null || _a === void 0 ? void 0 : _a.shape;
|
|
239
|
+
if (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {
|
|
240
|
+
throw new Error('Invalid useReturnValue hook');
|
|
241
|
+
}
|
|
242
|
+
return property[0].shape;
|
|
243
|
+
})();
|
|
244
|
+
return [
|
|
245
|
+
{
|
|
246
|
+
status,
|
|
247
|
+
contentType,
|
|
214
248
|
signature: responseType,
|
|
215
249
|
description: '',
|
|
216
250
|
errorMessage: '',
|
|
@@ -222,22 +256,32 @@ const parseRequestResponse = (node) => {
|
|
|
222
256
|
return [
|
|
223
257
|
{
|
|
224
258
|
status: responseType[0].shape === 'void' || responseType[0].shape === 'null' ? 204 : 200,
|
|
259
|
+
contentType: 'application/json',
|
|
225
260
|
signature: responseType[0].shape,
|
|
226
261
|
description: '',
|
|
227
262
|
errorMessage: '',
|
|
228
263
|
},
|
|
229
264
|
];
|
|
230
265
|
}
|
|
231
|
-
return responseType[0].shape.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
266
|
+
return responseType[0].shape.flatMap((unionEntry) => {
|
|
267
|
+
return parseResponseTypes([unionEntry]);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (responseType[0].role === 'buffer') {
|
|
271
|
+
return [
|
|
272
|
+
{
|
|
273
|
+
status: 200,
|
|
274
|
+
contentType: 'application/octet-stream',
|
|
275
|
+
signature: responseType,
|
|
276
|
+
description: '',
|
|
277
|
+
errorMessage: '',
|
|
278
|
+
},
|
|
279
|
+
];
|
|
237
280
|
}
|
|
238
281
|
return [
|
|
239
282
|
{
|
|
240
283
|
status: 200,
|
|
284
|
+
contentType: 'application/json',
|
|
241
285
|
signature: responseType,
|
|
242
286
|
description: '',
|
|
243
287
|
errorMessage: '',
|
|
@@ -7,6 +7,7 @@ const usePathParams_1 = require("../../../hooks/usePathParams");
|
|
|
7
7
|
const useQueryParams_1 = require("../../../hooks/useQueryParams");
|
|
8
8
|
const useRequestBody_1 = require("../../../hooks/useRequestBody");
|
|
9
9
|
const useRequestRawBody_1 = require("../../../hooks/useRequestRawBody");
|
|
10
|
+
const useReturnValue_1 = require("../../../hooks/useReturnValue");
|
|
10
11
|
const Router_1 = require("../../../router/Router");
|
|
11
12
|
const BuiltInValidators_1 = require("../../../validators/BuiltInValidators");
|
|
12
13
|
const ParamWrappers_1 = require("../../../validators/ParamWrappers");
|
|
@@ -398,3 +399,29 @@ router.patch('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
|
398
399
|
});
|
|
399
400
|
router.delete('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
400
401
|
});
|
|
402
|
+
router.get('/test/61ebf020-fe62-426b-8078-43fa0b29635b', () => {
|
|
403
|
+
return 'foo';
|
|
404
|
+
});
|
|
405
|
+
router.get('/test/5a39c1ff-5d17-4e9e-ad4b-56736bb01f67', () => {
|
|
406
|
+
return Buffer.from('foo');
|
|
407
|
+
});
|
|
408
|
+
router.get('/test/a47c9a37-a6cb-45bd-9460-e58562f179d4', () => {
|
|
409
|
+
return {
|
|
410
|
+
value: 'foo',
|
|
411
|
+
contentType: 'application/contentTypeThatIsNotRead',
|
|
412
|
+
};
|
|
413
|
+
});
|
|
414
|
+
router.get('/test/81202d25-c5ef-44f2-be20-f1442f25540d', () => {
|
|
415
|
+
return (0, useReturnValue_1.useReturnValue)('foo', 418, 'application/customContentType');
|
|
416
|
+
});
|
|
417
|
+
router.get('/test/2ec01787-13d0-4512-9cf3-468f409508b7', () => {
|
|
418
|
+
if (Math.random() > 0.5) {
|
|
419
|
+
return (0, useReturnValue_1.useReturnValue)('foo', 418, 'application/customContentType');
|
|
420
|
+
}
|
|
421
|
+
else if (Math.random() > 0.5) {
|
|
422
|
+
return 'foo';
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
value: 'foo',
|
|
426
|
+
};
|
|
427
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ShapeOfType = ShapeOfProperty | ShapeOfStringLiteral | ShapeOfNumberLiteral | ShapeOfUnion | ShapeOfUnionEntry | ShapeOfRecord | ShapeOfArray | ShapeOfRef | ShapeOfTuple | ShapeOfTupleEntry;
|
|
1
|
+
export type ShapeOfType = ShapeOfProperty | ShapeOfStringLiteral | ShapeOfNumberLiteral | ShapeOfUnion | ShapeOfUnionEntry | ShapeOfBuffer | ShapeOfRecord | ShapeOfArray | ShapeOfRef | ShapeOfTuple | ShapeOfTupleEntry;
|
|
2
2
|
export type ShapeOfProperty = {
|
|
3
3
|
role: 'property';
|
|
4
4
|
identifier: string;
|
|
@@ -25,6 +25,11 @@ export type ShapeOfUnionEntry = {
|
|
|
25
25
|
shape: string | ShapeOfType[];
|
|
26
26
|
optional: boolean;
|
|
27
27
|
};
|
|
28
|
+
export type ShapeOfBuffer = {
|
|
29
|
+
role: 'buffer';
|
|
30
|
+
shape: string;
|
|
31
|
+
optional: boolean;
|
|
32
|
+
};
|
|
28
33
|
export type ShapeOfRecord = {
|
|
29
34
|
role: 'record';
|
|
30
35
|
shape: string | ShapeOfType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACpB,eAAe,GACf,oBAAoB,GACpB,oBAAoB,GACpB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,iBAAiB,CAAA;AAEpB,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,aAAa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,CAAA;IACb,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;IAC7B,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePaths.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/generatePaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGvD,eAAO,MAAM,aAAa,cAAe,YAAY,EAAE,eAAe,kBAAkB;;;;;;
|
|
1
|
+
{"version":3,"file":"generatePaths.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/generatePaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGvD,eAAO,MAAM,aAAa,cAAe,YAAY,EAAE,eAAe,kBAAkB;;;;;;EAuIvF,CAAA"}
|
|
@@ -76,21 +76,20 @@ const generatePaths = (endpoints, preferences) => {
|
|
|
76
76
|
: undefined;
|
|
77
77
|
const responses = {};
|
|
78
78
|
endpoint.responses.forEach((response) => {
|
|
79
|
-
var _a, _b, _c;
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
80
|
const status = String(response.status);
|
|
81
|
-
const existingSchemas = (_c = (_b = (_a = responses[status]) === null || _a === void 0 ? void 0 : _a['content']) === null || _b === void 0 ? void 0 : _b[
|
|
81
|
+
const existingSchemas = (_d = (_c = (_b = (_a = responses[status]) === null || _a === void 0 ? void 0 : _a['content']) === null || _b === void 0 ? void 0 : _b[response.contentType]) === null || _c === void 0 ? void 0 : _c['schema']['oneOf']) !== null && _d !== void 0 ? _d : [];
|
|
82
82
|
const responseSchema = (0, getSchema_1.getSchema)(response.signature);
|
|
83
83
|
const content = (() => {
|
|
84
|
+
var _a;
|
|
84
85
|
if ('type' in responseSchema && (responseSchema.type === 'void' || responseSchema.type === 'null')) {
|
|
85
86
|
return undefined;
|
|
86
87
|
}
|
|
87
|
-
return {
|
|
88
|
-
'application/json': {
|
|
88
|
+
return Object.assign(Object.assign({}, (_a = responses[status]) === null || _a === void 0 ? void 0 : _a['content']), { [response.contentType]: {
|
|
89
89
|
schema: {
|
|
90
90
|
oneOf: [...existingSchemas, (0, getSchema_1.getSchema)(response.signature)],
|
|
91
91
|
},
|
|
92
|
-
}
|
|
93
|
-
};
|
|
92
|
+
} });
|
|
94
93
|
})();
|
|
95
94
|
responses[status] = {
|
|
96
95
|
description: response.description || '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchema.d.ts","sourceRoot":"","sources":["../../../../src/openapi/generatorModule/getSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,WAAW,EAEX,MAAM,oCAAoC,CAAA;AAE3C,MAAM,MAAM,UAAU,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAC5E;IAAE,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAA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CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnB,eAAO,MAAM,SAAS,UAAW,MAAM,GAAG,WAAW,EAAE,KAAG,UAoIzD,CAAA"}
|
|
@@ -107,6 +107,13 @@ const getSchema = (shape) => {
|
|
|
107
107
|
maxItems: tupleEntries.length,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
+
const isBuffer = shape[0].role === 'buffer';
|
|
111
|
+
if (isBuffer) {
|
|
112
|
+
return {
|
|
113
|
+
type: 'string',
|
|
114
|
+
format: 'binary',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
110
117
|
return {
|
|
111
118
|
type: 'unknown_21',
|
|
112
119
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openApiGenerator.spec.data.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/generatorModule/test/openApiGenerator.spec.data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,eAAO,MAAM,iBAAiB,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"openApiGenerator.spec.data.d.ts","sourceRoot":"","sources":["../../../../../src/openapi/generatorModule/test/openApiGenerator.spec.data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,eAAO,MAAM,iBAAiB,EAAE,YAAY,EA0vB3C,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuWhC,CAAA"}
|
|
@@ -11,7 +11,7 @@ exports.manyEndpointsData = [
|
|
|
11
11
|
requestHeaders: [],
|
|
12
12
|
rawBody: undefined,
|
|
13
13
|
objectBody: [],
|
|
14
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
14
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
15
15
|
name: 'Test endpoint name',
|
|
16
16
|
summary: 'Test endpoint summary',
|
|
17
17
|
description: 'Test endpoint description',
|
|
@@ -41,7 +41,7 @@ exports.manyEndpointsData = [
|
|
|
41
41
|
requestHeaders: [],
|
|
42
42
|
rawBody: undefined,
|
|
43
43
|
objectBody: [],
|
|
44
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
44
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
45
45
|
name: undefined,
|
|
46
46
|
summary: undefined,
|
|
47
47
|
description: undefined,
|
|
@@ -71,7 +71,7 @@ exports.manyEndpointsData = [
|
|
|
71
71
|
requestHeaders: [],
|
|
72
72
|
rawBody: undefined,
|
|
73
73
|
objectBody: [],
|
|
74
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
74
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
75
75
|
name: undefined,
|
|
76
76
|
summary: undefined,
|
|
77
77
|
description: undefined,
|
|
@@ -122,7 +122,7 @@ exports.manyEndpointsData = [
|
|
|
122
122
|
requestHeaders: [],
|
|
123
123
|
rawBody: undefined,
|
|
124
124
|
objectBody: [],
|
|
125
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
125
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
126
126
|
name: undefined,
|
|
127
127
|
summary: undefined,
|
|
128
128
|
description: undefined,
|
|
@@ -161,7 +161,7 @@ exports.manyEndpointsData = [
|
|
|
161
161
|
requestHeaders: [],
|
|
162
162
|
rawBody: undefined,
|
|
163
163
|
objectBody: [],
|
|
164
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
164
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
165
165
|
name: undefined,
|
|
166
166
|
summary: undefined,
|
|
167
167
|
description: undefined,
|
|
@@ -234,7 +234,7 @@ exports.manyEndpointsData = [
|
|
|
234
234
|
requestHeaders: [],
|
|
235
235
|
rawBody: undefined,
|
|
236
236
|
objectBody: [],
|
|
237
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
237
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
238
238
|
name: undefined,
|
|
239
239
|
summary: undefined,
|
|
240
240
|
description: undefined,
|
|
@@ -260,7 +260,7 @@ exports.manyEndpointsData = [
|
|
|
260
260
|
requestHeaders: [],
|
|
261
261
|
rawBody: undefined,
|
|
262
262
|
objectBody: [],
|
|
263
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
263
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
264
264
|
name: undefined,
|
|
265
265
|
summary: undefined,
|
|
266
266
|
description: undefined,
|
|
@@ -290,7 +290,7 @@ exports.manyEndpointsData = [
|
|
|
290
290
|
optional: false,
|
|
291
291
|
},
|
|
292
292
|
objectBody: [],
|
|
293
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
293
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
294
294
|
name: undefined,
|
|
295
295
|
summary: undefined,
|
|
296
296
|
description: undefined,
|
|
@@ -320,7 +320,7 @@ exports.manyEndpointsData = [
|
|
|
320
320
|
optional: false,
|
|
321
321
|
},
|
|
322
322
|
objectBody: [],
|
|
323
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
323
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
324
324
|
name: undefined,
|
|
325
325
|
summary: undefined,
|
|
326
326
|
description: undefined,
|
|
@@ -350,7 +350,7 @@ exports.manyEndpointsData = [
|
|
|
350
350
|
optional: true,
|
|
351
351
|
},
|
|
352
352
|
objectBody: [],
|
|
353
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
353
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
354
354
|
name: undefined,
|
|
355
355
|
summary: undefined,
|
|
356
356
|
description: undefined,
|
|
@@ -364,7 +364,7 @@ exports.manyEndpointsData = [
|
|
|
364
364
|
requestHeaders: [],
|
|
365
365
|
rawBody: { signature: 'boolean', optional: true },
|
|
366
366
|
objectBody: [],
|
|
367
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
367
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
368
368
|
name: undefined,
|
|
369
369
|
summary: undefined,
|
|
370
370
|
description: undefined,
|
|
@@ -390,7 +390,7 @@ exports.manyEndpointsData = [
|
|
|
390
390
|
},
|
|
391
391
|
{ identifier: 'thirdParam', signature: 'number', optional: true },
|
|
392
392
|
],
|
|
393
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
393
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
394
394
|
name: undefined,
|
|
395
395
|
summary: undefined,
|
|
396
396
|
description: undefined,
|
|
@@ -416,7 +416,7 @@ exports.manyEndpointsData = [
|
|
|
416
416
|
},
|
|
417
417
|
{ identifier: 'thirdParam', signature: 'number', optional: true },
|
|
418
418
|
],
|
|
419
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
419
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
420
420
|
name: undefined,
|
|
421
421
|
summary: undefined,
|
|
422
422
|
description: undefined,
|
|
@@ -442,7 +442,7 @@ exports.manyEndpointsData = [
|
|
|
442
442
|
},
|
|
443
443
|
{ identifier: 'thirdParam', signature: 'number', optional: true },
|
|
444
444
|
],
|
|
445
|
-
responses: [{ status: 200, signature: 'void' }],
|
|
445
|
+
responses: [{ status: 200, signature: 'void', contentType: 'application/json' }],
|
|
446
446
|
name: undefined,
|
|
447
447
|
summary: undefined,
|
|
448
448
|
description: undefined,
|
|
@@ -456,7 +456,7 @@ exports.manyEndpointsData = [
|
|
|
456
456
|
requestHeaders: [],
|
|
457
457
|
rawBody: undefined,
|
|
458
458
|
objectBody: [],
|
|
459
|
-
responses: [{ status: 200, signature: 'string' }],
|
|
459
|
+
responses: [{ status: 200, signature: 'string', contentType: 'application/json' }],
|
|
460
460
|
name: undefined,
|
|
461
461
|
summary: undefined,
|
|
462
462
|
description: undefined,
|
|
@@ -471,9 +471,9 @@ exports.manyEndpointsData = [
|
|
|
471
471
|
rawBody: undefined,
|
|
472
472
|
objectBody: [],
|
|
473
473
|
responses: [
|
|
474
|
-
{ status: 200, signature: 'boolean' },
|
|
475
|
-
{ status: 200, signature: 'string' },
|
|
476
|
-
{ status: 200, signature: 'number' },
|
|
474
|
+
{ status: 200, signature: 'boolean', contentType: 'application/json' },
|
|
475
|
+
{ status: 200, signature: 'string', contentType: 'application/json' },
|
|
476
|
+
{ status: 200, signature: 'number', contentType: 'application/json' },
|
|
477
477
|
],
|
|
478
478
|
name: undefined,
|
|
479
479
|
summary: undefined,
|
|
@@ -491,6 +491,7 @@ exports.manyEndpointsData = [
|
|
|
491
491
|
responses: [
|
|
492
492
|
{
|
|
493
493
|
status: 200,
|
|
494
|
+
contentType: 'application/json',
|
|
494
495
|
signature: [
|
|
495
496
|
{
|
|
496
497
|
role: 'property',
|
|
@@ -523,6 +524,7 @@ exports.manyEndpointsData = [
|
|
|
523
524
|
responses: [
|
|
524
525
|
{
|
|
525
526
|
status: 200,
|
|
527
|
+
contentType: 'application/json',
|
|
526
528
|
signature: [
|
|
527
529
|
{
|
|
528
530
|
role: 'property',
|
|
@@ -555,6 +557,7 @@ exports.manyEndpointsData = [
|
|
|
555
557
|
responses: [
|
|
556
558
|
{
|
|
557
559
|
status: 200,
|
|
560
|
+
contentType: 'application/json',
|
|
558
561
|
signature: [
|
|
559
562
|
{
|
|
560
563
|
role: 'property',
|
|
@@ -603,6 +606,7 @@ exports.manyEndpointsData = [
|
|
|
603
606
|
responses: [
|
|
604
607
|
{
|
|
605
608
|
status: 200,
|
|
609
|
+
contentType: 'application/json',
|
|
606
610
|
signature: [
|
|
607
611
|
{
|
|
608
612
|
role: 'property',
|
|
@@ -641,6 +645,7 @@ exports.manyEndpointsData = [
|
|
|
641
645
|
responses: [
|
|
642
646
|
{
|
|
643
647
|
status: 200,
|
|
648
|
+
contentType: 'application/json',
|
|
644
649
|
signature: [
|
|
645
650
|
{
|
|
646
651
|
role: 'property',
|
|
@@ -691,6 +696,7 @@ exports.manyEndpointsData = [
|
|
|
691
696
|
responses: [
|
|
692
697
|
{
|
|
693
698
|
status: 200,
|
|
699
|
+
contentType: 'application/json',
|
|
694
700
|
signature: [
|
|
695
701
|
{
|
|
696
702
|
role: 'property',
|
|
@@ -702,6 +708,7 @@ exports.manyEndpointsData = [
|
|
|
702
708
|
},
|
|
703
709
|
{
|
|
704
710
|
status: 200,
|
|
711
|
+
contentType: 'application/json',
|
|
705
712
|
signature: [
|
|
706
713
|
{
|
|
707
714
|
role: 'property',
|
|
@@ -737,7 +744,7 @@ exports.manyEndpointsData = [
|
|
|
737
744
|
requestHeaders: [],
|
|
738
745
|
rawBody: undefined,
|
|
739
746
|
objectBody: [],
|
|
740
|
-
responses: [{ status: 200, signature: 'object' }],
|
|
747
|
+
responses: [{ status: 200, signature: 'object', contentType: 'application/json' }],
|
|
741
748
|
name: undefined,
|
|
742
749
|
summary: undefined,
|
|
743
750
|
description: undefined,
|
|
@@ -751,7 +758,7 @@ exports.manyEndpointsData = [
|
|
|
751
758
|
requestHeaders: [],
|
|
752
759
|
rawBody: undefined,
|
|
753
760
|
objectBody: [],
|
|
754
|
-
responses: [{ status: 204, signature: 'void' }],
|
|
761
|
+
responses: [{ status: 204, signature: 'void', contentType: 'application/json' }],
|
|
755
762
|
name: undefined,
|
|
756
763
|
summary: undefined,
|
|
757
764
|
description: undefined,
|
|
@@ -15,13 +15,11 @@ export type PathDefinition = {
|
|
|
15
15
|
tags?: string[];
|
|
16
16
|
responses: Record<string, {
|
|
17
17
|
description: string;
|
|
18
|
-
content?: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
oneOf: SchemaType[];
|
|
22
|
-
};
|
|
18
|
+
content?: Record<string, {
|
|
19
|
+
schema: {
|
|
20
|
+
oneOf: SchemaType[];
|
|
23
21
|
};
|
|
24
|
-
}
|
|
22
|
+
}>;
|
|
25
23
|
}>;
|
|
26
24
|
};
|
|
27
25
|
export type ExposedModelData = {
|
|
@@ -73,6 +71,7 @@ export type EndpointData = {
|
|
|
73
71
|
responses: {
|
|
74
72
|
status: number;
|
|
75
73
|
signature: string | ShapeOfType[];
|
|
74
|
+
contentType: string;
|
|
76
75
|
description?: string;
|
|
77
76
|
errorMessage?: string;
|
|
78
77
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/openapi/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,KAAK,SAAS,GAAG;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC/B,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E,CAAC,EACP,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAYtE,MAAM,CAAC,CAAC,SAAS,MAAM,EAC7B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAYtE,GAAG,CAAC,CAAC,SAAS,MAAM,EAC1B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAYtE,KAAK,CAAC,CAAC,SAAS,MAAM,EAC5B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAYtE,MAAM;IAIN,cAAc;CAGrB"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Router = void 0;
|
|
7
7
|
const router_1 = __importDefault(require("@koa/router"));
|
|
8
8
|
const OpenApiManager_1 = require("../openapi/manager/OpenApiManager");
|
|
9
|
-
const
|
|
9
|
+
const parseEndpointReturnValue_1 = require("./parseEndpointReturnValue");
|
|
10
10
|
class Router {
|
|
11
11
|
constructor(props = { skipOpenApiAnalysis: false }) {
|
|
12
12
|
this.koaRouter = new router_1.default();
|
|
@@ -31,49 +31,55 @@ class Router {
|
|
|
31
31
|
}
|
|
32
32
|
get(path, callback) {
|
|
33
33
|
this.koaRouter.get(path, async (ctx) => {
|
|
34
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
35
34
|
const responseValue = await callback(ctx, undefined);
|
|
36
|
-
|
|
35
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
36
|
+
ctx.body = value;
|
|
37
|
+
ctx.set('Content-Type', contentType);
|
|
37
38
|
});
|
|
38
39
|
return this;
|
|
39
40
|
}
|
|
40
41
|
post(path, callback) {
|
|
41
42
|
this.koaRouter.post(path, async (ctx) => {
|
|
42
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
43
43
|
const responseValue = await callback(ctx, undefined);
|
|
44
|
-
|
|
44
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
45
|
+
ctx.body = value;
|
|
46
|
+
ctx.set('Content-Type', contentType);
|
|
45
47
|
});
|
|
46
48
|
return this;
|
|
47
49
|
}
|
|
48
50
|
put(path, callback) {
|
|
49
51
|
this.koaRouter.put(path, async (ctx) => {
|
|
50
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
51
52
|
const responseValue = await callback(ctx, undefined);
|
|
52
|
-
|
|
53
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
54
|
+
ctx.body = value;
|
|
55
|
+
ctx.set('Content-Type', contentType);
|
|
53
56
|
});
|
|
54
57
|
return this;
|
|
55
58
|
}
|
|
56
59
|
delete(path, callback) {
|
|
57
60
|
this.koaRouter.delete(path, async (ctx) => {
|
|
58
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
59
61
|
const responseValue = await callback(ctx, undefined);
|
|
60
|
-
|
|
62
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
63
|
+
ctx.body = value;
|
|
64
|
+
ctx.set('Content-Type', contentType);
|
|
61
65
|
});
|
|
62
66
|
return this;
|
|
63
67
|
}
|
|
64
68
|
del(path, callback) {
|
|
65
69
|
this.koaRouter.del(path, async (ctx) => {
|
|
66
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
67
70
|
const responseValue = await callback(ctx, undefined);
|
|
68
|
-
|
|
71
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
72
|
+
ctx.body = value;
|
|
73
|
+
ctx.set('Content-Type', contentType);
|
|
69
74
|
});
|
|
70
75
|
return this;
|
|
71
76
|
}
|
|
72
77
|
patch(path, callback) {
|
|
73
78
|
this.koaRouter.patch(path, async (ctx) => {
|
|
74
|
-
ctx.set('Content-Type', 'application/json; charset=utf-8');
|
|
75
79
|
const responseValue = await callback(ctx, undefined);
|
|
76
|
-
|
|
80
|
+
const { value, contentType } = (0, parseEndpointReturnValue_1.parseEndpointReturnValue)(responseValue);
|
|
81
|
+
ctx.body = value;
|
|
82
|
+
ctx.set('Content-Type', contentType);
|
|
77
83
|
});
|
|
78
84
|
return this;
|
|
79
85
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEndpointReturnValue.d.ts","sourceRoot":"","sources":["../../../src/router/parseEndpointReturnValue.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,aAAc,OAAO;;;;;;CA8BzD,CAAA"}
|