@tsed/schema 6.90.0 → 6.93.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/.mocharc.js +5 -0
- package/.nycrc +27 -0
- package/lib/cjs/components/anyMapper.js +0 -1
- package/lib/cjs/components/anyMapper.js.map +1 -1
- package/lib/cjs/components/classMapper.d.ts +1 -1
- package/lib/cjs/components/classMapper.js +1 -1
- package/lib/cjs/components/classMapper.js.map +1 -1
- package/lib/cjs/components/index.d.ts +2 -0
- package/lib/cjs/components/index.js +2 -0
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/inheritedClassMapper.d.ts +1 -1
- package/lib/cjs/components/inheritedClassMapper.js +1 -1
- package/lib/cjs/components/inheritedClassMapper.js.map +1 -1
- package/lib/cjs/components/mapMapper.d.ts +1 -1
- package/lib/cjs/components/mapMapper.js +1 -1
- package/lib/cjs/components/mapMapper.js.map +1 -1
- package/lib/cjs/components/objectMapper.js +4 -1
- package/lib/cjs/components/objectMapper.js.map +1 -1
- package/lib/cjs/components/ofMapper.d.ts +3 -0
- package/lib/cjs/components/ofMapper.js +17 -0
- package/lib/cjs/components/ofMapper.js.map +1 -0
- package/lib/cjs/components/propertiesMapper.d.ts +3 -0
- package/lib/cjs/components/propertiesMapper.js +25 -0
- package/lib/cjs/components/propertiesMapper.js.map +1 -0
- package/lib/cjs/components/schemaMapper.d.ts +1 -1
- package/lib/cjs/components/schemaMapper.js +29 -31
- package/lib/cjs/components/schemaMapper.js.map +1 -1
- package/lib/cjs/decorators/common/requiredGroups.d.ts +1 -1
- package/lib/cjs/decorators/common/requiredGroups.js +6 -9
- package/lib/cjs/decorators/common/requiredGroups.js.map +1 -1
- package/lib/cjs/decorators/index.d.ts +1 -0
- package/lib/cjs/decorators/index.js +1 -0
- package/lib/cjs/decorators/index.js.map +1 -1
- package/lib/cjs/decorators/operations/inFile.d.ts +25 -0
- package/lib/cjs/decorators/operations/inFile.js +45 -0
- package/lib/cjs/decorators/operations/inFile.js.map +1 -0
- package/lib/cjs/decorators/operations/route.d.ts +3 -0
- package/lib/cjs/decorators/operations/route.js +10 -8
- package/lib/cjs/decorators/operations/route.js.map +1 -1
- package/lib/cjs/domain/JsonEntityStore.d.ts +3 -0
- package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
- package/lib/cjs/domain/JsonMethodStore.d.ts +22 -1
- package/lib/cjs/domain/JsonMethodStore.js +42 -5
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/registries/JsonSchemaMapperContainer.d.ts +3 -2
- package/lib/cjs/registries/JsonSchemaMapperContainer.js +7 -3
- package/lib/cjs/registries/JsonSchemaMapperContainer.js.map +1 -1
- package/lib/cjs/utils/getJsonEntityStore.d.ts +0 -4
- package/lib/cjs/utils/getJsonEntityStore.js +1 -8
- package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
- package/lib/cjs/utils/getRequiredProperties.js +1 -2
- package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
- package/lib/cjs/utils/mapRouteOptions.d.ts +1 -1
- package/lib/cjs/utils/mapRouteOptions.js +1 -1
- package/lib/cjs/utils/mapRouteOptions.js.map +1 -1
- package/lib/esm/components/anyMapper.js +0 -1
- package/lib/esm/components/anyMapper.js.map +1 -1
- package/lib/esm/components/classMapper.js +1 -1
- package/lib/esm/components/classMapper.js.map +1 -1
- package/lib/esm/components/index.js +2 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/inheritedClassMapper.js +1 -1
- package/lib/esm/components/inheritedClassMapper.js.map +1 -1
- package/lib/esm/components/mapMapper.js +1 -1
- package/lib/esm/components/mapMapper.js.map +1 -1
- package/lib/esm/components/objectMapper.js +4 -1
- package/lib/esm/components/objectMapper.js.map +1 -1
- package/lib/esm/components/ofMapper.js +13 -0
- package/lib/esm/components/ofMapper.js.map +1 -0
- package/lib/esm/components/propertiesMapper.js +21 -0
- package/lib/esm/components/propertiesMapper.js.map +1 -0
- package/lib/esm/components/schemaMapper.js +30 -32
- package/lib/esm/components/schemaMapper.js.map +1 -1
- package/lib/esm/decorators/common/requiredGroups.js +6 -9
- package/lib/esm/decorators/common/requiredGroups.js.map +1 -1
- package/lib/esm/decorators/index.js +1 -0
- package/lib/esm/decorators/index.js.map +1 -1
- package/lib/esm/decorators/operations/inFile.js +41 -0
- package/lib/esm/decorators/operations/inFile.js.map +1 -0
- package/lib/esm/decorators/operations/route.js +10 -8
- package/lib/esm/decorators/operations/route.js.map +1 -1
- package/lib/esm/domain/JsonEntityStore.js.map +1 -1
- package/lib/esm/domain/JsonMethodStore.js +44 -7
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/registries/JsonSchemaMapperContainer.js +5 -2
- package/lib/esm/registries/JsonSchemaMapperContainer.js.map +1 -1
- package/lib/esm/utils/getJsonEntityStore.js +0 -6
- package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
- package/lib/esm/utils/getRequiredProperties.js +1 -2
- package/lib/esm/utils/getRequiredProperties.js.map +1 -1
- package/lib/esm/utils/mapRouteOptions.js +1 -1
- package/lib/esm/utils/mapRouteOptions.js.map +1 -1
- package/lib/types/components/classMapper.d.ts +1 -1
- package/lib/types/components/index.d.ts +2 -0
- package/lib/types/components/inheritedClassMapper.d.ts +1 -1
- package/lib/types/components/mapMapper.d.ts +1 -1
- package/lib/types/components/ofMapper.d.ts +3 -0
- package/lib/types/components/propertiesMapper.d.ts +3 -0
- package/lib/types/components/schemaMapper.d.ts +1 -1
- package/lib/types/decorators/common/requiredGroups.d.ts +1 -1
- package/lib/types/decorators/index.d.ts +1 -0
- package/lib/types/decorators/operations/inFile.d.ts +25 -0
- package/lib/types/decorators/operations/route.d.ts +3 -0
- package/lib/types/domain/JsonEntityStore.d.ts +3 -0
- package/lib/types/domain/JsonMethodStore.d.ts +22 -1
- package/lib/types/registries/JsonSchemaMapperContainer.d.ts +3 -2
- package/lib/types/utils/getJsonEntityStore.d.ts +0 -4
- package/lib/types/utils/mapRouteOptions.d.ts +1 -1
- package/package.json +7 -6
package/.mocharc.js
ADDED
package/.nycrc
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*.ts"
|
|
4
|
+
],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"**/*.d.ts",
|
|
7
|
+
"node_modules",
|
|
8
|
+
"**/interfaces/**",
|
|
9
|
+
"**/index.ts",
|
|
10
|
+
"**/*.spec.ts"
|
|
11
|
+
],
|
|
12
|
+
"extension": [
|
|
13
|
+
".ts"
|
|
14
|
+
],
|
|
15
|
+
"require": [],
|
|
16
|
+
"reporter": [
|
|
17
|
+
"text-summary",
|
|
18
|
+
"html",
|
|
19
|
+
"lcov",
|
|
20
|
+
"json"
|
|
21
|
+
],
|
|
22
|
+
"check-coverage": true,
|
|
23
|
+
"statements": 99.67,
|
|
24
|
+
"branches": 91.32,
|
|
25
|
+
"functions": 99.51,
|
|
26
|
+
"lines": 99.81
|
|
27
|
+
}
|
|
@@ -6,7 +6,6 @@ const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperConta
|
|
|
6
6
|
const generics_1 = require("../utils/generics");
|
|
7
7
|
const ref_1 = require("../utils/ref");
|
|
8
8
|
function anyMapper(input, options = {}) {
|
|
9
|
-
options.schemas = options.schemas || {};
|
|
10
9
|
if (typeof input !== "object" || input === null) {
|
|
11
10
|
return input;
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anyMapper.js","sourceRoot":"","sources":["../../../src/components/anyMapper.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAElD,uFAA6F;AAC7F,gDAAqD;AACrD,sCAAmC;AAEnC,SAAgB,SAAS,CAAC,KAAU,EAAE,UAA6B,EAAE;IACnE,
|
|
1
|
+
{"version":3,"file":"anyMapper.js","sourceRoot":"","sources":["../../../src/components/anyMapper.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAElD,uFAA6F;AAC7F,gDAAqD;AACrD,sCAAmC;AAEnC,SAAgB,SAAS,CAAC,KAAU,EAAE,UAA6B,EAAE;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,YAAY,yBAAW,EAAE;QAChC,OAAO,IAAA,sCAAU,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC9C;IAED,IAAI,QAAQ,IAAI,KAAK,EAAE;QACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAA,6BAAkB,EAAC,OAAO,CAAC,CAAC,CAAC;QAEzD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,WAAK,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;KAC9D;IAED,OAAO,IAAA,sCAAU,EAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAhBD,8BAgBC;AAED,IAAA,oDAAwB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {toRef} from \"../utils/ref\";\n\nexport function anyMapper(input: any, options: JsonSchemaOptions = {}): any {\n if (typeof input !== \"object\" || input === null) {\n return input;\n }\n\n if (input instanceof JsonLazyRef) {\n return execMapper(\"lazyRef\", input, options);\n }\n\n if (\"toJSON\" in input) {\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return input.canRef ? toRef(input, schema, options) : schema;\n }\n\n return execMapper(\"object\", input, options);\n}\n\nregisterJsonSchemaMapper(\"any\", anyMapper);\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonSchema } from "../domain/JsonSchema";
|
|
2
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function classMapper(value: JsonSchema, options
|
|
3
|
+
export declare function classMapper(value: JsonSchema, options: JsonSchemaOptions): any;
|
|
@@ -5,7 +5,7 @@ const JsonEntityStore_1 = require("../domain/JsonEntityStore");
|
|
|
5
5
|
const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
|
|
6
6
|
const generics_1 = require("../utils/generics");
|
|
7
7
|
const ref_1 = require("../utils/ref");
|
|
8
|
-
function classMapper(value, options
|
|
8
|
+
function classMapper(value, options) {
|
|
9
9
|
const store = JsonEntityStore_1.JsonEntityStore.from(value.class);
|
|
10
10
|
const name = (0, ref_1.createRefName)(store.schema.getName() || value.getName(), options);
|
|
11
11
|
if (value.hasGenerics) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classMapper.js","sourceRoot":"","sources":["../../../src/components/classMapper.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAG1D,uFAA6F;AAC7F,gDAAkE;AAClE,sCAAsD;AAEtD,SAAgB,WAAW,CAAC,KAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"classMapper.js","sourceRoot":"","sources":["../../../src/components/classMapper.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAG1D,uFAA6F;AAC7F,gDAAkE;AAClE,sCAAsD;AAEtD,SAAgB,WAAW,CAAC,KAAiB,EAAE,OAA0B;IACvE,MAAM,KAAK,GAAG,iCAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,IAAA,mBAAa,EAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAE/E,IAAI,KAAK,CAAC,WAAW,EAAE;QACrB,iBAAiB;QACjB,MAAM,EAAC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JsonSchema\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions, popGenerics} from \"../utils/generics\";\nimport {createRef, createRefName} from \"../utils/ref\";\n\nexport function classMapper(value: JsonSchema, options: JsonSchemaOptions) {\n const store = JsonEntityStore.from(value.class);\n const name = createRefName(store.schema.getName() || value.getName(), options);\n\n if (value.hasGenerics) {\n // Inline generic\n const {type, properties, additionalProperties, items, ...props} = value.toJSON(options);\n const schema = {\n ...execMapper(\"any\", store.schema, {\n ...options,\n ...popGenerics(value),\n root: false\n }),\n ...props\n };\n\n if (schema.title) {\n const name = createRefName(schema.title, options);\n options.schemas![name] = schema;\n delete schema.title;\n\n return createRef(name, value, options);\n }\n\n return schema;\n }\n\n if (options.schemas && !options.schemas[name]) {\n options.schemas[name] = {}; // avoid infinite calls\n options.schemas[name] = execMapper(\n \"any\",\n store.schema,\n mapGenericsOptions({\n ...options,\n root: false\n })\n );\n }\n\n return createRef(name, value, options);\n}\n\nregisterJsonSchemaMapper(\"class\", classMapper);\n"]}
|
|
@@ -10,4 +10,6 @@ const tslib_1 = require("tslib");
|
|
|
10
10
|
(0, tslib_1.__exportStar)(require("./mapMapper"), exports);
|
|
11
11
|
(0, tslib_1.__exportStar)(require("./objectMapper"), exports);
|
|
12
12
|
(0, tslib_1.__exportStar)(require("./schemaMapper"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./ofMapper"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./propertiesMapper"), exports);
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,2DAA4B;AAC5B,6DAA8B;AAC9B,gEAAiC;AACjC,sEAAuC;AACvC,4DAA6B;AAC7B,+DAAgC;AAChC,2DAA4B;AAC5B,8DAA+B;AAC/B,8DAA+B","sourcesContent":["export * from \"./anyMapper\";\nexport * from \"./classMapper\";\nexport * from \"./genericsMapper\";\nexport * from \"./inheritedClassMapper\";\nexport * from \"./itemMapper\";\nexport * from \"./lazyRefMapper\";\nexport * from \"./mapMapper\";\nexport * from \"./objectMapper\";\nexport * from \"./schemaMapper\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,2DAA4B;AAC5B,6DAA8B;AAC9B,gEAAiC;AACjC,sEAAuC;AACvC,4DAA6B;AAC7B,+DAAgC;AAChC,2DAA4B;AAC5B,8DAA+B;AAC/B,8DAA+B;AAC/B,0DAA2B;AAC3B,kEAAmC","sourcesContent":["export * from \"./anyMapper\";\nexport * from \"./classMapper\";\nexport * from \"./genericsMapper\";\nexport * from \"./inheritedClassMapper\";\nexport * from \"./itemMapper\";\nexport * from \"./lazyRefMapper\";\nexport * from \"./mapMapper\";\nexport * from \"./objectMapper\";\nexport * from \"./schemaMapper\";\nexport * from \"./ofMapper\";\nexport * from \"./propertiesMapper\";\n"]}
|
|
@@ -2,4 +2,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
|
2
2
|
/**
|
|
3
3
|
* @ignore
|
|
4
4
|
*/
|
|
5
|
-
export declare function inheritedClassMapper(obj: any, { target, ...options }
|
|
5
|
+
export declare function inheritedClassMapper(obj: any, { target, ...options }: JsonSchemaOptions): any;
|
|
@@ -7,7 +7,7 @@ const getInheritedStores_1 = require("../utils/getInheritedStores");
|
|
|
7
7
|
/**
|
|
8
8
|
* @ignore
|
|
9
9
|
*/
|
|
10
|
-
function inheritedClassMapper(obj, { target, ...options }
|
|
10
|
+
function inheritedClassMapper(obj, { target, ...options }) {
|
|
11
11
|
const stores = Array.from((0, getInheritedStores_1.getInheritedStores)(target).entries()).filter(([model]) => (0, core_1.classOf)(model) !== (0, core_1.classOf)(target));
|
|
12
12
|
if (stores.length) {
|
|
13
13
|
const schema = stores.reduce((obj, [, store]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inheritedClassMapper.js","sourceRoot":"","sources":["../../../src/components/inheritedClassMapper.ts"],"names":[],"mappings":";;;AAAA,qCAA8C;AAE9C,uFAA6F;AAC7F,oEAA+D;AAE/D;;GAEG;AACH,SAAgB,oBAAoB,CAAC,GAAQ,EAAE,EAAC,MAAM,EAAE,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"inheritedClassMapper.js","sourceRoot":"","sources":["../../../src/components/inheritedClassMapper.ts"],"names":[],"mappings":";;;AAAA,qCAA8C;AAE9C,uFAA6F;AAC7F,oEAA+D;AAE/D;;GAEG;AACH,SAAgB,oBAAoB,CAAC,GAAQ,EAAE,EAAC,MAAM,EAAE,GAAG,OAAO,EAAoB;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAA,uCAAkB,EAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,KAAK,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC;IAExH,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9C,OAAO,IAAA,gBAAS,EAAC,GAAG,EAAE,IAAA,sCAAU,EAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,GAAG,GAAG,IAAA,gBAAS,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAZD,oDAYC;AAED,IAAA,oDAAwB,EAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import {classOf, deepMerge} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getInheritedStores} from \"../utils/getInheritedStores\";\n\n/**\n * @ignore\n */\nexport function inheritedClassMapper(obj: any, {target, ...options}: JsonSchemaOptions) {\n const stores = Array.from(getInheritedStores(target).entries()).filter(([model]) => classOf(model) !== classOf(target));\n\n if (stores.length) {\n const schema = stores.reduce((obj, [, store]) => {\n return deepMerge(obj, execMapper(\"schema\", store.schema, options));\n }, {});\n\n obj = deepMerge(schema, obj);\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"inheritedClass\", inheritedClassMapper);\n"]}
|
|
@@ -6,4 +6,4 @@ import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
|
6
6
|
* @param options
|
|
7
7
|
* @ignore
|
|
8
8
|
*/
|
|
9
|
-
export declare function mapMapper(input: Map<string, any>, { ignore, ...options }
|
|
9
|
+
export declare function mapMapper(input: Map<string, any>, { ignore, ...options }: JsonSchemaOptions): any;
|
|
@@ -10,7 +10,7 @@ const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperConta
|
|
|
10
10
|
* @param options
|
|
11
11
|
* @ignore
|
|
12
12
|
*/
|
|
13
|
-
function mapMapper(input, { ignore = [], ...options }
|
|
13
|
+
function mapMapper(input, { ignore = [], ...options }) {
|
|
14
14
|
options = (0, generics_1.mapGenericsOptions)(options);
|
|
15
15
|
return Array.from(input.entries()).reduce((obj, [key, value]) => {
|
|
16
16
|
if (ignore.includes(key)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapMapper.js","sourceRoot":"","sources":["../../../src/components/mapMapper.ts"],"names":[],"mappings":";;;AAAA,gDAAqD;AAErD,uFAA6F;AAE7F;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAuB,EAAE,EAAC,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"mapMapper.js","sourceRoot":"","sources":["../../../src/components/mapMapper.ts"],"names":[],"mappings":";;;AAAA,gDAAqD;AAErD,uFAA6F;AAE7F;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAuB,EAAE,EAAC,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,EAAoB;IAC7F,OAAO,GAAG,IAAA,6BAAkB,EAAC,OAAO,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnE,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,GAAG,CAAC;SACZ;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAXD,8BAWC;AAED,IAAA,oDAAwB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import {mapGenericsOptions} from \"../utils/generics\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize class which inherit from Map like JsonMap, JsonOperation, JsonParameter.\n * @param input\n * @param ignore\n * @param options\n * @ignore\n */\nexport function mapMapper(input: Map<string, any>, {ignore = [], ...options}: JsonSchemaOptions): any {\n options = mapGenericsOptions(options);\n\n return Array.from(input.entries()).reduce((obj: any, [key, value]) => {\n if (ignore.includes(key)) {\n return obj;\n }\n\n obj[key] = execMapper(\"item\", value, options);\n return obj;\n }, {});\n}\n\nregisterJsonSchemaMapper(\"map\", mapMapper);\n"]}
|
|
@@ -15,7 +15,10 @@ function objectMapper(input, options) {
|
|
|
15
15
|
return Object.entries(input).reduce((obj, [key, value]) => {
|
|
16
16
|
if (options.withIgnoredProps !== false && !(0, alterIgnore_1.alterIgnore)(value, ctx)) {
|
|
17
17
|
// remove groups to avoid bad schema generation over children models
|
|
18
|
-
obj[key] = (0, JsonSchemaMapperContainer_1.execMapper)("item", value, {
|
|
18
|
+
obj[key] = (0, JsonSchemaMapperContainer_1.execMapper)("item", value, {
|
|
19
|
+
...options,
|
|
20
|
+
groups: (input === null || input === void 0 ? void 0 : input.$forwardGroups) || (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined
|
|
21
|
+
});
|
|
19
22
|
}
|
|
20
23
|
return obj;
|
|
21
24
|
}, (0, core_1.isArray)(input) ? [] : {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,sDAAiD;AAEjD,uFAA6F;AAE7F;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC,sDAAiD;AAEjD,uFAA6F;AAE7F;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE;gBACnC,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC,CAAC;SACJ;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAjBD,oCAiBC;AAED,IAAA,oDAAwB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n });\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ofMapper = void 0;
|
|
4
|
+
const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
|
|
5
|
+
function ofMapper(input, options, parent) {
|
|
6
|
+
return input.map((value) => {
|
|
7
|
+
return (0, JsonSchemaMapperContainer_1.execMapper)("item", value, {
|
|
8
|
+
...options,
|
|
9
|
+
genericLabels: parent.genericLabels
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.ofMapper = ofMapper;
|
|
14
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("anyOf", ofMapper);
|
|
15
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("allOf", ofMapper);
|
|
16
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("oneOf", ofMapper);
|
|
17
|
+
//# sourceMappingURL=ofMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ofMapper.js","sourceRoot":"","sources":["../../../src/components/ofMapper.ts"],"names":[],"mappings":";;;AAAA,uFAA6F;AAI7F,SAAgB,QAAQ,CAAC,KAA2B,EAAE,OAA0B,EAAE,MAAkB;IAClG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAuB,EAAE,EAAE;QAC3C,OAAO,IAAA,sCAAU,EAAC,MAAM,EAAE,KAAK,EAAE;YAC/B,GAAG,OAAO;YACV,aAAa,EAAE,MAAM,CAAC,aAAa;SACpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,4BAOC;AAED,IAAA,oDAAwB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5C,IAAA,oDAAwB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5C,IAAA,oDAAwB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nexport function ofMapper(input: (any | JsonSchema)[], options: JsonSchemaOptions, parent: JsonSchema) {\n return input.map((value: any | JsonSchema) => {\n return execMapper(\"item\", value, {\n ...options,\n genericLabels: parent.genericLabels\n });\n });\n}\n\nregisterJsonSchemaMapper(\"anyOf\", ofMapper);\nregisterJsonSchemaMapper(\"allOf\", ofMapper);\nregisterJsonSchemaMapper(\"oneOf\", ofMapper);\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.propertiesMapper = void 0;
|
|
4
|
+
const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
|
|
5
|
+
function propertiesMapper(input, options, parent) {
|
|
6
|
+
if (input.isClass) {
|
|
7
|
+
return (0, JsonSchemaMapperContainer_1.execMapper)("class", input, options);
|
|
8
|
+
}
|
|
9
|
+
return (0, JsonSchemaMapperContainer_1.execMapper)("any", input, {
|
|
10
|
+
...options,
|
|
11
|
+
genericLabels: parent.genericLabels
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.propertiesMapper = propertiesMapper;
|
|
15
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("properties", propertiesMapper);
|
|
16
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("items", propertiesMapper);
|
|
17
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("additionalProperties", propertiesMapper);
|
|
18
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("propertyNames", propertiesMapper);
|
|
19
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("contains", propertiesMapper);
|
|
20
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("dependencies", propertiesMapper);
|
|
21
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("patternProperties", propertiesMapper);
|
|
22
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("additionalItems", propertiesMapper);
|
|
23
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("not", propertiesMapper);
|
|
24
|
+
(0, JsonSchemaMapperContainer_1.registerJsonSchemaMapper)("definitions", propertiesMapper);
|
|
25
|
+
//# sourceMappingURL=propertiesMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertiesMapper.js","sourceRoot":"","sources":["../../../src/components/propertiesMapper.ts"],"names":[],"mappings":";;;AAAA,uFAA6F;AAI7F,SAAgB,gBAAgB,CAAC,KAAuB,EAAE,OAA0B,EAAE,MAAkB;IACtG,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,IAAA,sCAAU,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC5C;IAED,OAAO,IAAA,sCAAU,EAAC,KAAK,EAAE,KAAK,EAAE;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;AACL,CAAC;AATD,4CASC;AAED,IAAA,oDAAwB,EAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACzD,IAAA,oDAAwB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACpD,IAAA,oDAAwB,EAAC,sBAAsB,EAAE,gBAAgB,CAAC,CAAC;AACnE,IAAA,oDAAwB,EAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAC5D,IAAA,oDAAwB,EAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AACvD,IAAA,oDAAwB,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAC3D,IAAA,oDAAwB,EAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAChE,IAAA,oDAAwB,EAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;AAC9D,IAAA,oDAAwB,EAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAClD,IAAA,oDAAwB,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nexport function propertiesMapper(input: any | JsonSchema, options: JsonSchemaOptions, parent: JsonSchema) {\n if (input.isClass) {\n return execMapper(\"class\", input, options);\n }\n\n return execMapper(\"any\", input, {\n ...options,\n genericLabels: parent.genericLabels\n });\n}\n\nregisterJsonSchemaMapper(\"properties\", propertiesMapper);\nregisterJsonSchemaMapper(\"items\", propertiesMapper);\nregisterJsonSchemaMapper(\"additionalProperties\", propertiesMapper);\nregisterJsonSchemaMapper(\"propertyNames\", propertiesMapper);\nregisterJsonSchemaMapper(\"contains\", propertiesMapper);\nregisterJsonSchemaMapper(\"dependencies\", propertiesMapper);\nregisterJsonSchemaMapper(\"patternProperties\", propertiesMapper);\nregisterJsonSchemaMapper(\"additionalItems\", propertiesMapper);\nregisterJsonSchemaMapper(\"not\", propertiesMapper);\nregisterJsonSchemaMapper(\"definitions\", propertiesMapper);\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonSchema } from "../domain/JsonSchema";
|
|
2
2
|
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions";
|
|
3
|
-
export declare function schemaMapper(schema: JsonSchema, options
|
|
3
|
+
export declare function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any;
|
|
@@ -37,46 +37,44 @@ function shouldSkipKey(key, { specType = SpecTypes_1.SpecTypes.JSON, customKeys
|
|
|
37
37
|
(specType === SpecTypes_1.SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||
|
|
38
38
|
(specType !== SpecTypes_1.SpecTypes.JSON && IGNORES_OPENSPEC.includes(key)));
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
function isExample(key, value, options) {
|
|
41
|
+
return key === "examples" && (0, core_1.isObject)(value) && [SpecTypes_1.SpecTypes.OPENAPI, SpecTypes_1.SpecTypes.SWAGGER].includes(options.specType);
|
|
42
|
+
}
|
|
43
|
+
function schemaMapper(schema, options) {
|
|
44
|
+
const { useAlias = true, schemas = {} } = options;
|
|
45
|
+
options = {
|
|
46
|
+
...options,
|
|
47
|
+
useAlias,
|
|
48
|
+
schemas
|
|
49
|
+
};
|
|
50
|
+
let obj = [...schema.keys()]
|
|
51
|
+
.filter((key) => !shouldSkipKey(key, options))
|
|
52
|
+
.reduce((item, key) => {
|
|
53
|
+
let value = schema.get(key);
|
|
46
54
|
key = key.replace(/^#/, "");
|
|
47
55
|
if (key === "type") {
|
|
48
|
-
|
|
56
|
+
return {
|
|
57
|
+
...item,
|
|
58
|
+
[key]: schema.getJsonType()
|
|
59
|
+
};
|
|
49
60
|
}
|
|
50
|
-
if (key
|
|
61
|
+
if (isExample(key, value, options)) {
|
|
51
62
|
key = "example";
|
|
52
63
|
value = Object.values(value)[0];
|
|
53
64
|
}
|
|
54
|
-
if (value) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
useAlias,
|
|
59
|
-
schemas
|
|
60
|
-
});
|
|
65
|
+
if (value && typeof value === "object" && (0, JsonSchemaMapperContainer_1.hasMapper)(key)) {
|
|
66
|
+
value = (0, JsonSchemaMapperContainer_1.execMapper)(key, value, options, schema);
|
|
67
|
+
if (isEmptyProperties(key, value)) {
|
|
68
|
+
return item;
|
|
61
69
|
}
|
|
62
|
-
|
|
63
|
-
value = (0,
|
|
64
|
-
...options,
|
|
65
|
-
useAlias,
|
|
66
|
-
schemas,
|
|
67
|
-
genericTypes,
|
|
68
|
-
genericLabels: schema.genericLabels
|
|
69
|
-
});
|
|
70
|
+
if (shouldMapAlias(key, value, useAlias)) {
|
|
71
|
+
value = (0, JsonAliasMap_1.mapAliasedProperties)(value, schema.alias);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
value = (0, JsonAliasMap_1.mapAliasedProperties)(value, schema.alias);
|
|
77
|
-
}
|
|
78
|
-
item[key] = value;
|
|
79
|
-
return item;
|
|
74
|
+
return {
|
|
75
|
+
...item,
|
|
76
|
+
[key]: value
|
|
77
|
+
};
|
|
80
78
|
}, {});
|
|
81
79
|
if (schema.isClass) {
|
|
82
80
|
obj = (0, JsonSchemaMapperContainer_1.execMapper)("inheritedClass", obj, { ...options, root: false, schemas, target: schema.getComputedType() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,yDAA4D;AAE5D,mDAA8C;AAE9C,
|
|
1
|
+
{"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schema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G,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;IACjE,GAAG,GAAG,IAAA,iCAAe,EAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE;QAC3E,OAAO,GAAG,CAAC,IAAI,CAAC;KACjB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAlED,oCAkEC;AAED,IAAA,oDAAwB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\nconst IGNORES_OS2 = [\"writeOnly\", \"readOnly\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType!);\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n\n if ((obj.oneOf || obj.allOf || obj.anyOf) && !(obj.items || obj.properties)) {\n delete obj.type;\n }\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequiredGroups = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
4
|
const matchGroups_1 = require("../../utils/matchGroups");
|
|
6
5
|
const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
7
6
|
/**
|
|
@@ -15,14 +14,12 @@ const jsonEntityFn_1 = require("./jsonEntityFn");
|
|
|
15
14
|
*/
|
|
16
15
|
function RequiredGroups(...groups) {
|
|
17
16
|
return (0, jsonEntityFn_1.JsonEntityFn)((entity) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
}
|
|
17
|
+
entity.parent.schema.$hooks.on("requiredGroups", (required, givenGroups) => {
|
|
18
|
+
if ((0, matchGroups_1.matchGroups)(groups, givenGroups)) {
|
|
19
|
+
return required.filter((key) => key !== entity.propertyKey);
|
|
20
|
+
}
|
|
21
|
+
return required;
|
|
22
|
+
});
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
exports.RequiredGroups = RequiredGroups;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requiredGroups.js","sourceRoot":"","sources":["../../../../src/decorators/common/requiredGroups.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"requiredGroups.js","sourceRoot":"","sources":["../../../../src/decorators/common/requiredGroups.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AACpD,iDAA4C;AAE5C;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,GAAG,MAAgB;IAChD,OAAO,IAAA,2BAAY,EAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAkB,EAAE,WAAqB,EAAE,EAAE;YAC7F,IAAI,IAAA,yBAAW,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE;gBACpC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,WAAW,CAAC,CAAC;aACrE;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,wCAUC","sourcesContent":["import {matchGroups} from \"../../utils/matchGroups\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * Apply groups validation strategy for required property.\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n */\nexport function RequiredGroups(...groups: string[]): PropertyDecorator {\n return JsonEntityFn((entity) => {\n entity.parent.schema.$hooks.on(\"requiredGroups\", (required: string[], givenGroups: string[]) => {\n if (matchGroups(groups, givenGroups)) {\n return required.filter((key: string) => key !== entity.propertyKey);\n }\n\n return required;\n });\n });\n}\n"]}
|
|
@@ -12,6 +12,7 @@ export * from "./operations/deprecated";
|
|
|
12
12
|
export * from "./operations/consumes";
|
|
13
13
|
export * from "./operations/contentType";
|
|
14
14
|
export * from "./operations/in";
|
|
15
|
+
export * from "./operations/inFile";
|
|
15
16
|
export * from "./operations/operationId";
|
|
16
17
|
export * from "./operations/operationPath";
|
|
17
18
|
export * from "./operations/path";
|
|
@@ -19,6 +19,7 @@ const tslib_1 = require("tslib");
|
|
|
19
19
|
(0, tslib_1.__exportStar)(require("./operations/consumes"), exports);
|
|
20
20
|
(0, tslib_1.__exportStar)(require("./operations/contentType"), exports);
|
|
21
21
|
(0, tslib_1.__exportStar)(require("./operations/in"), exports);
|
|
22
|
+
(0, tslib_1.__exportStar)(require("./operations/inFile"), exports);
|
|
22
23
|
(0, tslib_1.__exportStar)(require("./operations/operationId"), exports);
|
|
23
24
|
(0, tslib_1.__exportStar)(require("./operations/operationPath"), exports);
|
|
24
25
|
(0, tslib_1.__exportStar)(require("./operations/path"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,QAAQ;AACR,gEAAiC;AAEjC,cAAc;AACd,gFAAiD;AACjD,0EAA2C;AAC3C,sEAAuC;AACvC,sEAAuC;AACvC,yEAA0C;AAC1C,2EAA4C;AAC5C,2EAA4C;AAE5C,WAAW;AACX,mEAAoC;AACpC,oEAAqC;AAErC,aAAa;AACb,uEAAwC;AACxC,qEAAsC;AACtC,wEAAyC;AACzC,+DAAgC;AAChC,wEAAyC;AACzC,0EAA2C;AAC3C,iEAAkC;AAClC,qEAAsC;AACtC,oEAAqC;AACrC,mEAAoC;AACpC,mEAAoC;AACpC,qEAAsC;AACtC,iEAAkC;AAClC,oEAAqC;AACrC,oEAAqC;AACrC,qEAAsC;AACtC,qEAAsC;AACtC,kEAAmC;AAEnC,SAAS;AACT,6EAA8C;AAC9C,8DAA+B;AAC/B,4DAA6B;AAC7B,gEAAiC;AACjC,8DAA+B;AAC/B,gEAAiC;AACjC,oEAAqC;AACrC,gEAAiC;AACjC,iEAAkC;AAClC,6DAA8B;AAC9B,yEAA0C;AAC1C,yEAA0C;AAC1C,+DAAgC;AAChC,sEAAuC;AACvC,+DAAgC;AAChC,gEAAiC;AACjC,+DAAgC;AAChC,gEAAiC;AACjC,kEAAmC;AACnC,gEAAiC;AACjC,kEAAmC;AACnC,mEAAoC;AACpC,6DAA8B;AAC9B,iEAAkC;AAClC,uEAAwC;AACxC,iEAAkC;AAClC,+DAAgC;AAChC,8DAA+B;AAC/B,+DAAgC;AAChC,8DAA+B;AAC/B,8DAA+B;AAC/B,8DAA+B;AAC/B,qEAAsC;AACtC,iEAAkC;AAClC,kEAAmC;AACnC,iEAAkC;AAClC,kEAAmC;AACnC,iEAAkC;AAClC,4EAA6C","sourcesContent":["// class\nexport * from \"./class/children\";\n\n// collections\nexport * from \"./collections/collectionContains\";\nexport * from \"./collections/collectionOf\";\nexport * from \"./collections/maxItems\";\nexport * from \"./collections/minItems\";\nexport * from \"./collections/uniqueItems\";\nexport * from \"./collections/maxProperties\";\nexport * from \"./collections/minProperties\";\n\n// generics\nexport * from \"./generics/generics\";\nexport * from \"./generics/genericOf\";\n\n// operations\nexport * from \"./operations/deprecated\";\nexport * from \"./operations/consumes\";\nexport * from \"./operations/contentType\";\nexport * from \"./operations/in\";\nexport * from \"./operations/operationId\";\nexport * from \"./operations/operationPath\";\nexport * from \"./operations/path\";\nexport * from \"./operations/produces\";\nexport * from \"./operations/returns\";\nexport * from \"./operations/status\";\nexport * from \"./operations/header\";\nexport * from \"./operations/security\";\nexport * from \"./operations/tags\";\nexport * from \"./operations/summary\";\nexport * from \"./operations/partial\";\nexport * from \"./operations/redirect\";\nexport * from \"./operations/location\";\nexport * from \"./operations/route\";\n\n// common\nexport * from \"./common/additionalProperties\";\nexport * from \"./common/allow\";\nexport * from \"./common/any\";\nexport * from \"./common/integer\";\nexport * from \"./common/const\";\nexport * from \"./common/default\";\nexport * from \"./common/description\";\nexport * from \"./common/example\";\nexport * from \"./common/examples\";\nexport * from \"./common/enum\";\nexport * from \"./common/exclusiveMaximum\";\nexport * from \"./common/exclusiveMinimum\";\nexport * from \"./common/format\";\nexport * from \"./common/forwardGroups\";\nexport * from \"./common/groups\";\nexport * from \"./common/pattern\";\nexport * from \"./common/ignore\";\nexport * from \"./common/maximum\";\nexport * from \"./common/maxLength\";\nexport * from \"./common/minimum\";\nexport * from \"./common/minLength\";\nexport * from \"./common/multipleOf\";\nexport * from \"./common/name\";\nexport * from \"./common/required\";\nexport * from \"./common/requiredGroups\";\nexport * from \"./common/property\";\nexport * from \"./common/hidden\";\nexport * from \"./common/title\";\nexport * from \"./common/schema\";\nexport * from \"./common/oneOf\";\nexport * from \"./common/allOf\";\nexport * from \"./common/anyOf\";\nexport * from \"./common/jsonEntityFn\";\nexport * from \"./common/optional\";\nexport * from \"./common/writeOnly\";\nexport * from \"./common/readOnly\";\nexport * from \"./common/customKey\";\nexport * from \"./common/nullable\";\nexport * from \"./config/jsonEntityComponent\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,QAAQ;AACR,gEAAiC;AAEjC,cAAc;AACd,gFAAiD;AACjD,0EAA2C;AAC3C,sEAAuC;AACvC,sEAAuC;AACvC,yEAA0C;AAC1C,2EAA4C;AAC5C,2EAA4C;AAE5C,WAAW;AACX,mEAAoC;AACpC,oEAAqC;AAErC,aAAa;AACb,uEAAwC;AACxC,qEAAsC;AACtC,wEAAyC;AACzC,+DAAgC;AAChC,mEAAoC;AACpC,wEAAyC;AACzC,0EAA2C;AAC3C,iEAAkC;AAClC,qEAAsC;AACtC,oEAAqC;AACrC,mEAAoC;AACpC,mEAAoC;AACpC,qEAAsC;AACtC,iEAAkC;AAClC,oEAAqC;AACrC,oEAAqC;AACrC,qEAAsC;AACtC,qEAAsC;AACtC,kEAAmC;AAEnC,SAAS;AACT,6EAA8C;AAC9C,8DAA+B;AAC/B,4DAA6B;AAC7B,gEAAiC;AACjC,8DAA+B;AAC/B,gEAAiC;AACjC,oEAAqC;AACrC,gEAAiC;AACjC,iEAAkC;AAClC,6DAA8B;AAC9B,yEAA0C;AAC1C,yEAA0C;AAC1C,+DAAgC;AAChC,sEAAuC;AACvC,+DAAgC;AAChC,gEAAiC;AACjC,+DAAgC;AAChC,gEAAiC;AACjC,kEAAmC;AACnC,gEAAiC;AACjC,kEAAmC;AACnC,mEAAoC;AACpC,6DAA8B;AAC9B,iEAAkC;AAClC,uEAAwC;AACxC,iEAAkC;AAClC,+DAAgC;AAChC,8DAA+B;AAC/B,+DAAgC;AAChC,8DAA+B;AAC/B,8DAA+B;AAC/B,8DAA+B;AAC/B,qEAAsC;AACtC,iEAAkC;AAClC,kEAAmC;AACnC,iEAAkC;AAClC,kEAAmC;AACnC,iEAAkC;AAClC,4EAA6C","sourcesContent":["// class\nexport * from \"./class/children\";\n\n// collections\nexport * from \"./collections/collectionContains\";\nexport * from \"./collections/collectionOf\";\nexport * from \"./collections/maxItems\";\nexport * from \"./collections/minItems\";\nexport * from \"./collections/uniqueItems\";\nexport * from \"./collections/maxProperties\";\nexport * from \"./collections/minProperties\";\n\n// generics\nexport * from \"./generics/generics\";\nexport * from \"./generics/genericOf\";\n\n// operations\nexport * from \"./operations/deprecated\";\nexport * from \"./operations/consumes\";\nexport * from \"./operations/contentType\";\nexport * from \"./operations/in\";\nexport * from \"./operations/inFile\";\nexport * from \"./operations/operationId\";\nexport * from \"./operations/operationPath\";\nexport * from \"./operations/path\";\nexport * from \"./operations/produces\";\nexport * from \"./operations/returns\";\nexport * from \"./operations/status\";\nexport * from \"./operations/header\";\nexport * from \"./operations/security\";\nexport * from \"./operations/tags\";\nexport * from \"./operations/summary\";\nexport * from \"./operations/partial\";\nexport * from \"./operations/redirect\";\nexport * from \"./operations/location\";\nexport * from \"./operations/route\";\n\n// common\nexport * from \"./common/additionalProperties\";\nexport * from \"./common/allow\";\nexport * from \"./common/any\";\nexport * from \"./common/integer\";\nexport * from \"./common/const\";\nexport * from \"./common/default\";\nexport * from \"./common/description\";\nexport * from \"./common/example\";\nexport * from \"./common/examples\";\nexport * from \"./common/enum\";\nexport * from \"./common/exclusiveMaximum\";\nexport * from \"./common/exclusiveMinimum\";\nexport * from \"./common/format\";\nexport * from \"./common/forwardGroups\";\nexport * from \"./common/groups\";\nexport * from \"./common/pattern\";\nexport * from \"./common/ignore\";\nexport * from \"./common/maximum\";\nexport * from \"./common/maxLength\";\nexport * from \"./common/minimum\";\nexport * from \"./common/minLength\";\nexport * from \"./common/multipleOf\";\nexport * from \"./common/name\";\nexport * from \"./common/required\";\nexport * from \"./common/requiredGroups\";\nexport * from \"./common/property\";\nexport * from \"./common/hidden\";\nexport * from \"./common/title\";\nexport * from \"./common/schema\";\nexport * from \"./common/oneOf\";\nexport * from \"./common/allOf\";\nexport * from \"./common/anyOf\";\nexport * from \"./common/jsonEntityFn\";\nexport * from \"./common/optional\";\nexport * from \"./common/writeOnly\";\nexport * from \"./common/readOnly\";\nexport * from \"./common/customKey\";\nexport * from \"./common/nullable\";\nexport * from \"./config/jsonEntityComponent\";\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a input file parameter.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.
|
|
6
|
+
* But you can use this decorator on Method, to add extra in parameters like Authorization header.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller("/")
|
|
10
|
+
* class MyController {
|
|
11
|
+
* @Post("/")
|
|
12
|
+
* method(@InFile("file1") file: any) {
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
* :::
|
|
17
|
+
*
|
|
18
|
+
* @decorator
|
|
19
|
+
* @swagger
|
|
20
|
+
* @schema
|
|
21
|
+
* @input
|
|
22
|
+
* @operation
|
|
23
|
+
* @param name
|
|
24
|
+
*/
|
|
25
|
+
export declare function InFile(name: string): ParameterDecorator;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InFile = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const in_1 = require("./in");
|
|
6
|
+
const JsonParameterTypes_1 = require("../../domain/JsonParameterTypes");
|
|
7
|
+
const returns_1 = require("./returns");
|
|
8
|
+
const name_1 = require("../common/name");
|
|
9
|
+
const consumes_1 = require("./consumes");
|
|
10
|
+
/**
|
|
11
|
+
* Add a input file parameter.
|
|
12
|
+
*
|
|
13
|
+
* ::: warning
|
|
14
|
+
* Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.
|
|
15
|
+
* But you can use this decorator on Method, to add extra in parameters like Authorization header.
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* @Controller("/")
|
|
19
|
+
* class MyController {
|
|
20
|
+
* @Post("/")
|
|
21
|
+
* method(@InFile("file1") file: any) {
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
* :::
|
|
26
|
+
*
|
|
27
|
+
* @decorator
|
|
28
|
+
* @swagger
|
|
29
|
+
* @schema
|
|
30
|
+
* @input
|
|
31
|
+
* @operation
|
|
32
|
+
* @param name
|
|
33
|
+
*/
|
|
34
|
+
function InFile(name) {
|
|
35
|
+
return (...args) => {
|
|
36
|
+
const [target, propertyKey, index] = args;
|
|
37
|
+
const multiple = core_1.Metadata.getParamTypes(target, propertyKey)[index] === Array;
|
|
38
|
+
name = (typeof name === "object" ? undefined : name);
|
|
39
|
+
const expression = [name, !multiple && "0"].filter(Boolean).join(".");
|
|
40
|
+
const decorators = (0, core_1.useDecorators)((0, in_1.In)(JsonParameterTypes_1.JsonParameterTypes.FILES), (0, name_1.Name)(expression), (0, core_1.useMethodDecorators)((0, returns_1.Returns)(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), (0, consumes_1.Consumes)("multipart/form-data")));
|
|
41
|
+
decorators(...args);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.InFile = InFile;
|
|
45
|
+
//# sourceMappingURL=inFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inFile.js","sourceRoot":"","sources":["../../../../src/decorators/operations/inFile.ts"],"names":[],"mappings":";;;AAAA,qCAA6F;AAC7F,6BAAwB;AACxB,wEAAmE;AACnE,uCAAkC;AAClC,yCAAoC;AACpC,yCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,MAAM,CAAC,IAAY;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,IAAA,oBAAa,EAC9B,IAAA,OAAE,EAAC,uCAAkB,CAAC,KAAK,CAAC,EAC5B,IAAA,WAAI,EAAC,UAAU,CAAC,EAChB,IAAA,0BAAmB,EACjB,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC,WAAW,CACtB,+KAA+K,CAChL,EACD,IAAA,mBAAQ,EAAC,qBAAqB,CAAC,CAChC,CACF,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAtBD,wBAsBC","sourcesContent":["import {DecoratorParameters, Metadata, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {In} from \"./in\";\nimport {JsonParameterTypes} from \"../../domain/JsonParameterTypes\";\nimport {Returns} from \"./returns\";\nimport {Name} from \"../common/name\";\nimport {Consumes} from \"./consumes\";\n\n/**\n * Add a input file parameter.\n *\n * ::: warning\n * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.\n * But you can use this decorator on Method, to add extra in parameters like Authorization header.\n *\n * ```typescript\n * @Controller(\"/\")\n * class MyController {\n * @Post(\"/\")\n * method(@InFile(\"file1\") file: any) {\n * }\n * }\n * ```\n * :::\n *\n * @decorator\n * @swagger\n * @schema\n * @input\n * @operation\n * @param name\n */\nexport function InFile(name: string): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n In(JsonParameterTypes.FILES),\n Name(expression),\n useMethodDecorators(\n Returns(400).Description(\n `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`\n ),\n Consumes(\"multipart/form-data\")\n )\n );\n\n decorators(...args);\n };\n}\n"]}
|
|
@@ -32,6 +32,9 @@ export interface RouteChainedDecorators {
|
|
|
32
32
|
* @param Summary
|
|
33
33
|
*/
|
|
34
34
|
Summary(Summary: string): this;
|
|
35
|
+
Use(...args: any[]): this;
|
|
36
|
+
UseAfter(...args: any[]): this;
|
|
37
|
+
UseBefore(...args: any[]): this;
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Describe a new route with a method and path.
|