@tsed/schema 8.0.1 → 8.0.3
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/package.json +11 -10
- package/readme.md +6 -6
- package/src/components/async-api/channelsMapper.ts +81 -0
- package/src/components/async-api/generate.ts +24 -0
- package/src/components/async-api/messageMapper.ts +62 -0
- package/src/components/async-api/payloadMapper.ts +61 -0
- package/src/components/async-api/responseMapper.ts +70 -0
- package/src/components/default/anyMapper.spec.ts +7 -0
- package/src/components/default/anyMapper.ts +33 -0
- package/src/components/default/classMapper.ts +55 -0
- package/src/components/default/discriminatorMappingMapper.ts +36 -0
- package/src/components/default/enumsMapper.spec.ts +64 -0
- package/src/components/default/enumsMapper.ts +17 -0
- package/src/components/default/genericsMapper.ts +70 -0
- package/src/components/default/inheritedClassMapper.ts +24 -0
- package/src/components/default/itemMapper.ts +8 -0
- package/src/components/default/lazyRefMapper.ts +21 -0
- package/src/components/default/mapMapper.ts +25 -0
- package/src/components/default/nullableMapper.ts +55 -0
- package/src/components/default/objectMapper.ts +36 -0
- package/src/components/default/ofMapper.ts +16 -0
- package/src/components/default/propertiesMapper.ts +25 -0
- package/src/components/default/requiredMapper.ts +69 -0
- package/src/components/default/schemaMapper.ts +151 -0
- package/src/components/index.ts +36 -0
- package/src/components/open-spec/discriminatorMappingMapper.ts +7 -0
- package/src/components/open-spec/enumsMapper.ts +20 -0
- package/src/components/open-spec/generate.ts +29 -0
- package/src/components/open-spec/nullableMapper.ts +51 -0
- package/src/components/open-spec/operationInFilesMapper.ts +32 -0
- package/src/components/open-spec/operationInParameterMapper.ts +56 -0
- package/src/components/open-spec/operationInParametersMapper.ts +9 -0
- package/src/components/open-spec/operationInQueryMapper.ts +74 -0
- package/src/components/open-spec/operationMapper.ts +65 -0
- package/src/components/open-spec/operationMediaMapper.ts +11 -0
- package/src/components/open-spec/operationRequestBodyMapper.ts +82 -0
- package/src/components/open-spec/operationResponseMapper.ts +26 -0
- package/src/components/open-spec/pathsMapper.ts +132 -0
- package/src/constants/OperationVerbs.ts +29 -0
- package/src/constants/httpStatusMessages.ts +21 -0
- package/src/constants/jsonSchemaProperties.ts +17 -0
- package/src/decorators/class/children.ts +22 -0
- package/src/decorators/class/discriminatorValue.ts +53 -0
- package/src/decorators/collections/collectionContains.ts +25 -0
- package/src/decorators/collections/collectionOf.spec.ts +327 -0
- package/src/decorators/collections/collectionOf.ts +182 -0
- package/src/decorators/collections/maxItems.spec.ts +40 -0
- package/src/decorators/collections/maxItems.ts +59 -0
- package/src/decorators/collections/maxProperties.spec.ts +109 -0
- package/src/decorators/collections/maxProperties.ts +82 -0
- package/src/decorators/collections/minItems.spec.ts +40 -0
- package/src/decorators/collections/minItems.ts +63 -0
- package/src/decorators/collections/minProperties.spec.ts +109 -0
- package/src/decorators/collections/minProperties.ts +81 -0
- package/src/decorators/collections/uniqueItems.spec.ts +28 -0
- package/src/decorators/collections/uniqueItems.ts +59 -0
- package/src/decorators/common/__snapshots__/groups.spec.ts.snap +321 -0
- package/src/decorators/common/additionalProperties.spec.ts +133 -0
- package/src/decorators/common/additionalProperties.ts +17 -0
- package/src/decorators/common/allOf.spec.ts +276 -0
- package/src/decorators/common/allOf.ts +19 -0
- package/src/decorators/common/allow.spec.ts +130 -0
- package/src/decorators/common/allow.ts +50 -0
- package/src/decorators/common/any.spec.ts +109 -0
- package/src/decorators/common/any.ts +45 -0
- package/src/decorators/common/anyOf.spec.ts +270 -0
- package/src/decorators/common/anyOf.ts +23 -0
- package/src/decorators/common/const.spec.ts +98 -0
- package/src/decorators/common/const.ts +68 -0
- package/src/decorators/common/customKey.spec.ts +105 -0
- package/src/decorators/common/customKey.ts +39 -0
- package/src/decorators/common/default.spec.ts +25 -0
- package/src/decorators/common/default.ts +47 -0
- package/src/decorators/common/defaultMsg.spec.ts +22 -0
- package/src/decorators/common/defaultMsg.ts +38 -0
- package/src/decorators/common/description.spec.ts +166 -0
- package/src/decorators/common/description.ts +77 -0
- package/src/decorators/common/discriminatorKey.ts +14 -0
- package/src/decorators/common/enum.spec.ts +305 -0
- package/src/decorators/common/enum.ts +111 -0
- package/src/decorators/common/errorMsg.spec.ts +57 -0
- package/src/decorators/common/errorMsg.ts +14 -0
- package/src/decorators/common/example.spec.ts +93 -0
- package/src/decorators/common/example.ts +18 -0
- package/src/decorators/common/examples.spec.ts +101 -0
- package/src/decorators/common/examples.ts +20 -0
- package/src/decorators/common/exclusiveMaximum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMaximum.ts +75 -0
- package/src/decorators/common/exclusiveMinimum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMinimum.ts +75 -0
- package/src/decorators/common/format.spec.ts +149 -0
- package/src/decorators/common/format.ts +486 -0
- package/src/decorators/common/forwardGroups.spec.ts +270 -0
- package/src/decorators/common/forwardGroups.ts +16 -0
- package/src/decorators/common/groups.spec.ts +968 -0
- package/src/decorators/common/groups.ts +66 -0
- package/src/decorators/common/hidden.spec.ts +52 -0
- package/src/decorators/common/hidden.ts +36 -0
- package/src/decorators/common/ignore.spec.ts +88 -0
- package/src/decorators/common/ignore.ts +66 -0
- package/src/decorators/common/integer.spec.ts +110 -0
- package/src/decorators/common/integer.ts +69 -0
- package/src/decorators/common/jsonEntityFn.spec.ts +16 -0
- package/src/decorators/common/jsonEntityFn.ts +33 -0
- package/src/decorators/common/maxLength.spec.ts +61 -0
- package/src/decorators/common/maxLength.ts +88 -0
- package/src/decorators/common/maximum.spec.ts +73 -0
- package/src/decorators/common/maximum.ts +146 -0
- package/src/decorators/common/minLength.spec.ts +186 -0
- package/src/decorators/common/minLength.ts +89 -0
- package/src/decorators/common/minimum.spec.ts +74 -0
- package/src/decorators/common/minimum.ts +145 -0
- package/src/decorators/common/multipleOf.spec.ts +33 -0
- package/src/decorators/common/multipleOf.ts +80 -0
- package/src/decorators/common/name.spec.ts +56 -0
- package/src/decorators/common/name.ts +50 -0
- package/src/decorators/common/nullable.spec.ts +818 -0
- package/src/decorators/common/nullable.ts +32 -0
- package/src/decorators/common/oneOf.spec.ts +301 -0
- package/src/decorators/common/oneOf.ts +24 -0
- package/src/decorators/common/optional.spec.ts +43 -0
- package/src/decorators/common/optional.ts +26 -0
- package/src/decorators/common/pattern.spec.ts +27 -0
- package/src/decorators/common/pattern.ts +102 -0
- package/src/decorators/common/property.ts +24 -0
- package/src/decorators/common/readOnly.spec.ts +135 -0
- package/src/decorators/common/readOnly.ts +17 -0
- package/src/decorators/common/recordOf.spec.ts +41 -0
- package/src/decorators/common/recordOf.ts +59 -0
- package/src/decorators/common/required.spec.ts +188 -0
- package/src/decorators/common/required.ts +50 -0
- package/src/decorators/common/requiredGroups.spec.ts +127 -0
- package/src/decorators/common/requiredGroups.ts +23 -0
- package/src/decorators/common/schema.spec.ts +23 -0
- package/src/decorators/common/schema.ts +64 -0
- package/src/decorators/common/title.spec.ts +20 -0
- package/src/decorators/common/title.ts +45 -0
- package/src/decorators/common/typeError.spec.ts +22 -0
- package/src/decorators/common/typeError.ts +15 -0
- package/src/decorators/common/writeOnly.spec.ts +105 -0
- package/src/decorators/common/writeOnly.ts +17 -0
- package/src/decorators/config/jsonEntityComponent.ts +16 -0
- package/src/decorators/generics/genericOf.spec.ts +246 -0
- package/src/decorators/generics/genericOf.ts +112 -0
- package/src/decorators/generics/generics.ts +22 -0
- package/src/decorators/operations/acceptMime.spec.ts +39 -0
- package/src/decorators/operations/acceptMime.ts +25 -0
- package/src/decorators/operations/consumes.spec.ts +89 -0
- package/src/decorators/operations/consumes.ts +37 -0
- package/src/decorators/operations/contentType.spec.ts +40 -0
- package/src/decorators/operations/contentType.ts +24 -0
- package/src/decorators/operations/deprecated.spec.ts +223 -0
- package/src/decorators/operations/deprecated.ts +49 -0
- package/src/decorators/operations/header.spec.ts +214 -0
- package/src/decorators/operations/header.ts +62 -0
- package/src/decorators/operations/in.spec.ts +321 -0
- package/src/decorators/operations/in.ts +141 -0
- package/src/decorators/operations/inFile.spec.ts +209 -0
- package/src/decorators/operations/inFile.ts +55 -0
- package/src/decorators/operations/location.spec.ts +51 -0
- package/src/decorators/operations/location.ts +26 -0
- package/src/decorators/operations/operation.ts +119 -0
- package/src/decorators/operations/operationId.spec.ts +43 -0
- package/src/decorators/operations/operationId.ts +22 -0
- package/src/decorators/operations/operationPath.spec.ts +42 -0
- package/src/decorators/operations/operationPath.ts +33 -0
- package/src/decorators/operations/partial.spec.ts +249 -0
- package/src/decorators/operations/partial.ts +14 -0
- package/src/decorators/operations/path.spec.ts +47 -0
- package/src/decorators/operations/path.ts +27 -0
- package/src/decorators/operations/produces.spec.ts +89 -0
- package/src/decorators/operations/produces.ts +44 -0
- package/src/decorators/operations/publish.spec.ts +26 -0
- package/src/decorators/operations/publish.ts +6 -0
- package/src/decorators/operations/redirect.spec.ts +146 -0
- package/src/decorators/operations/redirect.ts +82 -0
- package/src/decorators/operations/returns.spec.ts +1393 -0
- package/src/decorators/operations/returns.ts +662 -0
- package/src/decorators/operations/route.spec.ts +211 -0
- package/src/decorators/operations/route.ts +154 -0
- package/src/decorators/operations/security.spec.ts +162 -0
- package/src/decorators/operations/security.ts +83 -0
- package/src/decorators/operations/status.spec.ts +582 -0
- package/src/decorators/operations/status.ts +130 -0
- package/src/decorators/operations/subscribe.spec.ts +32 -0
- package/src/decorators/operations/subscribe.ts +6 -0
- package/src/decorators/operations/summary.spec.ts +45 -0
- package/src/decorators/operations/summary.ts +32 -0
- package/src/decorators/operations/tags.spec.ts +113 -0
- package/src/decorators/operations/tags.ts +53 -0
- package/src/decorators/operations/view.spec.ts +16 -0
- package/src/decorators/operations/view.ts +27 -0
- package/src/domain/DecoratorContext.ts +116 -0
- package/src/domain/JsonAliasMap.ts +19 -0
- package/src/domain/JsonClassStore.ts +35 -0
- package/src/domain/JsonDiscriminator.spec.ts +65 -0
- package/src/domain/JsonDiscriminator.ts +52 -0
- package/src/domain/JsonEntityStore.spec.ts +277 -0
- package/src/domain/JsonEntityStore.ts +284 -0
- package/src/domain/JsonFormatTypes.ts +17 -0
- package/src/domain/JsonLazyRef.ts +21 -0
- package/src/domain/JsonMap.spec.ts +15 -0
- package/src/domain/JsonMap.ts +33 -0
- package/src/domain/JsonMedia.ts +24 -0
- package/src/domain/JsonMethodStore.spec.ts +301 -0
- package/src/domain/JsonMethodStore.ts +212 -0
- package/src/domain/JsonOperation.spec.ts +126 -0
- package/src/domain/JsonOperation.ts +219 -0
- package/src/domain/JsonOperationPathsMap.ts +16 -0
- package/src/domain/JsonOperationRoute.spec.ts +109 -0
- package/src/domain/JsonOperationRoute.ts +75 -0
- package/src/domain/JsonParameter.ts +70 -0
- package/src/domain/JsonParameterStore.spec.ts +212 -0
- package/src/domain/JsonParameterStore.ts +138 -0
- package/src/domain/JsonParameterTypes.spec.ts +12 -0
- package/src/domain/JsonParameterTypes.ts +20 -0
- package/src/domain/JsonPropertyStore.spec.ts +177 -0
- package/src/domain/JsonPropertyStore.ts +92 -0
- package/src/domain/JsonRequestBody.ts +47 -0
- package/src/domain/JsonResponse.spec.ts +33 -0
- package/src/domain/JsonResponse.ts +64 -0
- package/src/domain/JsonSchema.spec.ts +1470 -0
- package/src/domain/JsonSchema.ts +1049 -0
- package/src/domain/SpecTypes.ts +6 -0
- package/src/hooks/alterIgnore.ts +25 -0
- package/src/hooks/alterOneOf.ts +67 -0
- package/src/hooks/alterRequiredGroups.ts +12 -0
- package/src/index.ts +185 -0
- package/src/interfaces/IgnoreCallback.ts +5 -0
- package/src/interfaces/JsonHookContext.ts +18 -0
- package/src/interfaces/JsonOpenSpec.ts +7 -0
- package/src/interfaces/JsonSchemaOptions.ts +35 -0
- package/src/registries/JsonSchemaMapperContainer.ts +52 -0
- package/src/registries/enumRegistries.ts +3 -0
- package/src/utils/__snapshots__/generateSpec.spec.ts.snap +109 -0
- package/src/utils/buildPath.ts +8 -0
- package/src/utils/concatParameters.ts +12 -0
- package/src/utils/concatPath.spec.ts +23 -0
- package/src/utils/concatPath.ts +24 -0
- package/src/utils/defineStatusModel.ts +11 -0
- package/src/utils/from.spec.ts +243 -0
- package/src/utils/from.ts +281 -0
- package/src/utils/generateSpec.spec.ts +1262 -0
- package/src/utils/generateSpec.ts +54 -0
- package/src/utils/generics.ts +83 -0
- package/src/utils/getComputedType.spec.ts +45 -0
- package/src/utils/getComputedType.ts +39 -0
- package/src/utils/getInheritedStores.spec.ts +47 -0
- package/src/utils/getInheritedStores.ts +23 -0
- package/src/utils/getJsonEntityStore.ts +36 -0
- package/src/utils/getJsonPathParameters.spec.ts +126 -0
- package/src/utils/getJsonPathParameters.ts +97 -0
- package/src/utils/getJsonSchema.spec.ts +695 -0
- package/src/utils/getJsonSchema.ts +69 -0
- package/src/utils/getJsonType.spec.ts +28 -0
- package/src/utils/getJsonType.ts +46 -0
- package/src/utils/getOperationsRoutes.spec.ts +284 -0
- package/src/utils/getOperationsRoutes.ts +56 -0
- package/src/utils/getOperationsStore.spec.ts +47 -0
- package/src/utils/getOperationsStores.ts +37 -0
- package/src/utils/getPropertiesStores.spec.ts +138 -0
- package/src/utils/getPropertiesStores.ts +66 -0
- package/src/utils/getSpec.spec.ts +610 -0
- package/src/utils/getSpec.ts +117 -0
- package/src/utils/getSpecType.spec.ts +16 -0
- package/src/utils/getSpecType.ts +19 -0
- package/src/utils/isSuccessStatus.spec.ts +22 -0
- package/src/utils/isSuccessStatus.ts +2 -0
- package/src/utils/mapHeaders.spec.ts +57 -0
- package/src/utils/mapHeaders.ts +33 -0
- package/src/utils/mapOpenSpec.ts +44 -0
- package/src/utils/mapOpenSpec2.ts +50 -0
- package/src/utils/mapOpenSpec3.ts +25 -0
- package/src/utils/mapOpenSpecInfo.ts +19 -0
- package/src/utils/mapOperationOptions.ts +34 -0
- package/src/utils/matchGroups.spec.ts +85 -0
- package/src/utils/matchGroups.ts +64 -0
- package/src/utils/mergeSpec.spec.ts +533 -0
- package/src/utils/mergeSpec.ts +54 -0
- package/src/utils/operationIdFormatter.spec.ts +11 -0
- package/src/utils/operationIdFormatter.ts +49 -0
- package/src/utils/ref.ts +65 -0
- package/src/utils/removeHiddenOperation.ts +5 -0
- package/src/utils/serializeEnumValues.ts +27 -0
- package/src/utils/somethingOf.ts +11 -0
- package/src/utils/toJsonMapCollection.spec.ts +18 -0
- package/src/utils/toJsonMapCollection.ts +12 -0
- package/src/utils/toJsonRegex.ts +7 -0
- package/src/utils/transformToOS2.spec.ts +177 -0
- package/src/utils/transformToOS2.ts +607 -0
- package/src/utils/withErrorMsg.spec.ts +16 -0
- package/src/utils/withErrorMsg.ts +56 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {isBoolean} from "@tsed/core";
|
|
2
|
+
import type {Hooks} from "@tsed/hooks";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
* @param schema
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
export function alterIgnore(schema: {$hooks: Hooks; $ignore: boolean | Function}, options: any) {
|
|
10
|
+
if (isBoolean(schema.$ignore) && schema.$ignore) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let result = schema?.$hooks?.alter("ignore", false, [options]);
|
|
15
|
+
|
|
16
|
+
if (result) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (options.groups !== false) {
|
|
21
|
+
return schema?.$hooks?.alter("groups", false, [options.groups]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {isArray, isBoolean, isNumber, isObject, isString} from "@tsed/core";
|
|
2
|
+
import type {JSONSchema6} from "json-schema";
|
|
3
|
+
import {filter} from "rxjs";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ARRAY_PROPERTIES,
|
|
7
|
+
BOOLEAN_PROPERTIES,
|
|
8
|
+
COMMON_PROPERTIES,
|
|
9
|
+
MANY_OF_PROPERTIES,
|
|
10
|
+
NUMBER_PROPERTIES,
|
|
11
|
+
OBJECT_PROPERTIES,
|
|
12
|
+
STRING_PROPERTIES
|
|
13
|
+
} from "../constants/jsonSchemaProperties.js";
|
|
14
|
+
import type {JsonSchema} from "../domain/JsonSchema.js";
|
|
15
|
+
import type {JsonSchemaOptions} from "../interfaces/JsonSchemaOptions.js";
|
|
16
|
+
|
|
17
|
+
function findManyOf(obj: any) {
|
|
18
|
+
return MANY_OF_PROPERTIES.find((keyword) => obj[keyword]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const RULES: {[index: string]: {properties: string[]; is: (value: any) => boolean}} = {
|
|
22
|
+
string: {properties: STRING_PROPERTIES, is: isString},
|
|
23
|
+
number: {properties: NUMBER_PROPERTIES, is: isNumber},
|
|
24
|
+
boolean: {properties: BOOLEAN_PROPERTIES, is: isBoolean},
|
|
25
|
+
array: {properties: ARRAY_PROPERTIES, is: () => false},
|
|
26
|
+
object: {properties: OBJECT_PROPERTIES, is: () => false}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function pickProperties(type: string, obj: JSONSchema6 & Record<string, never>, item: Record<string, never>) {
|
|
30
|
+
const rule = RULES[type];
|
|
31
|
+
|
|
32
|
+
rule?.properties.concat(COMMON_PROPERTIES).forEach((keyword) => {
|
|
33
|
+
if (obj[keyword] !== undefined) {
|
|
34
|
+
if (COMMON_PROPERTIES.includes(keyword)) {
|
|
35
|
+
item[keyword] = (obj[keyword] as never[]).filter(rule.is) as never;
|
|
36
|
+
} else {
|
|
37
|
+
item[keyword] = obj[keyword] as never;
|
|
38
|
+
delete obj[keyword];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function alterOneOf(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {
|
|
45
|
+
const kind = findManyOf(obj);
|
|
46
|
+
|
|
47
|
+
if (kind) {
|
|
48
|
+
obj[kind].forEach((item: {type: string} & Record<string, never>) => {
|
|
49
|
+
pickProperties(item.type as string, obj, item);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
MANY_OF_PROPERTIES.forEach((keyword) => {
|
|
53
|
+
if (obj[keyword] && options.groups !== false && schema.$hooks.has(keyword)) {
|
|
54
|
+
obj = {...obj, [keyword]: schema.$hooks.alter(keyword, obj[keyword], [options.groups])};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
delete obj.const;
|
|
59
|
+
delete obj.enum;
|
|
60
|
+
|
|
61
|
+
if (!(obj.items || obj.properties)) {
|
|
62
|
+
delete obj.type;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {JsonSchema} from "../domain/JsonSchema.js";
|
|
2
|
+
import type {JsonSchemaOptions} from "../interfaces/JsonSchemaOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export function alterRequiredGroups(required: string[], schema: JsonSchema, options: JsonSchemaOptions): string[] {
|
|
7
|
+
if (options.groups !== false) {
|
|
8
|
+
return schema?.$hooks?.alter("requiredGroups", required, [options.groups]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return required;
|
|
12
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./components/async-api/channelsMapper.js";
|
|
5
|
+
export * from "./components/async-api/generate.js";
|
|
6
|
+
export * from "./components/async-api/messageMapper.js";
|
|
7
|
+
export * from "./components/async-api/payloadMapper.js";
|
|
8
|
+
export * from "./components/async-api/responseMapper.js";
|
|
9
|
+
export * from "./components/default/anyMapper.js";
|
|
10
|
+
export * from "./components/default/classMapper.js";
|
|
11
|
+
export * from "./components/default/discriminatorMappingMapper.js";
|
|
12
|
+
export * from "./components/default/enumsMapper.js";
|
|
13
|
+
export * from "./components/default/genericsMapper.js";
|
|
14
|
+
export * from "./components/default/inheritedClassMapper.js";
|
|
15
|
+
export * from "./components/default/itemMapper.js";
|
|
16
|
+
export * from "./components/default/lazyRefMapper.js";
|
|
17
|
+
export * from "./components/default/mapMapper.js";
|
|
18
|
+
export * from "./components/default/nullableMapper.js";
|
|
19
|
+
export * from "./components/default/objectMapper.js";
|
|
20
|
+
export * from "./components/default/ofMapper.js";
|
|
21
|
+
export * from "./components/default/propertiesMapper.js";
|
|
22
|
+
export * from "./components/default/requiredMapper.js";
|
|
23
|
+
export * from "./components/default/schemaMapper.js";
|
|
24
|
+
export * from "./components/index.js";
|
|
25
|
+
export * from "./components/open-spec/discriminatorMappingMapper.js";
|
|
26
|
+
export * from "./components/open-spec/enumsMapper.js";
|
|
27
|
+
export * from "./components/open-spec/generate.js";
|
|
28
|
+
export * from "./components/open-spec/nullableMapper.js";
|
|
29
|
+
export * from "./components/open-spec/operationInFilesMapper.js";
|
|
30
|
+
export * from "./components/open-spec/operationInParameterMapper.js";
|
|
31
|
+
export * from "./components/open-spec/operationInParametersMapper.js";
|
|
32
|
+
export * from "./components/open-spec/operationInQueryMapper.js";
|
|
33
|
+
export * from "./components/open-spec/operationMapper.js";
|
|
34
|
+
export * from "./components/open-spec/operationMediaMapper.js";
|
|
35
|
+
export * from "./components/open-spec/operationRequestBodyMapper.js";
|
|
36
|
+
export * from "./components/open-spec/operationResponseMapper.js";
|
|
37
|
+
export * from "./components/open-spec/pathsMapper.js";
|
|
38
|
+
export * from "./constants/httpStatusMessages.js";
|
|
39
|
+
export * from "./constants/jsonSchemaProperties.js";
|
|
40
|
+
export * from "./constants/OperationVerbs.js";
|
|
41
|
+
export * from "./decorators/class/children.js";
|
|
42
|
+
export * from "./decorators/class/discriminatorValue.js";
|
|
43
|
+
export * from "./decorators/collections/collectionContains.js";
|
|
44
|
+
export * from "./decorators/collections/collectionOf.js";
|
|
45
|
+
export * from "./decorators/collections/maxItems.js";
|
|
46
|
+
export * from "./decorators/collections/maxProperties.js";
|
|
47
|
+
export * from "./decorators/collections/minItems.js";
|
|
48
|
+
export * from "./decorators/collections/minProperties.js";
|
|
49
|
+
export * from "./decorators/collections/uniqueItems.js";
|
|
50
|
+
export * from "./decorators/common/additionalProperties.js";
|
|
51
|
+
export * from "./decorators/common/allOf.js";
|
|
52
|
+
export * from "./decorators/common/allow.js";
|
|
53
|
+
export * from "./decorators/common/any.js";
|
|
54
|
+
export * from "./decorators/common/anyOf.js";
|
|
55
|
+
export * from "./decorators/common/const.js";
|
|
56
|
+
export * from "./decorators/common/customKey.js";
|
|
57
|
+
export * from "./decorators/common/default.js";
|
|
58
|
+
export * from "./decorators/common/defaultMsg.js";
|
|
59
|
+
export * from "./decorators/common/description.js";
|
|
60
|
+
export * from "./decorators/common/discriminatorKey.js";
|
|
61
|
+
export * from "./decorators/common/enum.js";
|
|
62
|
+
export * from "./decorators/common/errorMsg.js";
|
|
63
|
+
export * from "./decorators/common/example.js";
|
|
64
|
+
export * from "./decorators/common/examples.js";
|
|
65
|
+
export * from "./decorators/common/exclusiveMaximum.js";
|
|
66
|
+
export * from "./decorators/common/exclusiveMinimum.js";
|
|
67
|
+
export * from "./decorators/common/format.js";
|
|
68
|
+
export * from "./decorators/common/forwardGroups.js";
|
|
69
|
+
export * from "./decorators/common/groups.js";
|
|
70
|
+
export * from "./decorators/common/hidden.js";
|
|
71
|
+
export * from "./decorators/common/ignore.js";
|
|
72
|
+
export * from "./decorators/common/integer.js";
|
|
73
|
+
export * from "./decorators/common/jsonEntityFn.js";
|
|
74
|
+
export * from "./decorators/common/maximum.js";
|
|
75
|
+
export * from "./decorators/common/maxLength.js";
|
|
76
|
+
export * from "./decorators/common/minimum.js";
|
|
77
|
+
export * from "./decorators/common/minLength.js";
|
|
78
|
+
export * from "./decorators/common/multipleOf.js";
|
|
79
|
+
export * from "./decorators/common/name.js";
|
|
80
|
+
export * from "./decorators/common/nullable.js";
|
|
81
|
+
export * from "./decorators/common/oneOf.js";
|
|
82
|
+
export * from "./decorators/common/optional.js";
|
|
83
|
+
export * from "./decorators/common/pattern.js";
|
|
84
|
+
export * from "./decorators/common/property.js";
|
|
85
|
+
export * from "./decorators/common/readOnly.js";
|
|
86
|
+
export * from "./decorators/common/recordOf.js";
|
|
87
|
+
export * from "./decorators/common/required.js";
|
|
88
|
+
export * from "./decorators/common/requiredGroups.js";
|
|
89
|
+
export * from "./decorators/common/schema.js";
|
|
90
|
+
export * from "./decorators/common/title.js";
|
|
91
|
+
export * from "./decorators/common/typeError.js";
|
|
92
|
+
export * from "./decorators/common/writeOnly.js";
|
|
93
|
+
export * from "./decorators/config/jsonEntityComponent.js";
|
|
94
|
+
export * from "./decorators/generics/genericOf.js";
|
|
95
|
+
export * from "./decorators/generics/generics.js";
|
|
96
|
+
export * from "./decorators/operations/acceptMime.js";
|
|
97
|
+
export * from "./decorators/operations/consumes.js";
|
|
98
|
+
export * from "./decorators/operations/contentType.js";
|
|
99
|
+
export * from "./decorators/operations/deprecated.js";
|
|
100
|
+
export * from "./decorators/operations/header.js";
|
|
101
|
+
export * from "./decorators/operations/in.js";
|
|
102
|
+
export * from "./decorators/operations/inFile.js";
|
|
103
|
+
export * from "./decorators/operations/location.js";
|
|
104
|
+
export * from "./decorators/operations/operation.js";
|
|
105
|
+
export * from "./decorators/operations/operationId.js";
|
|
106
|
+
export * from "./decorators/operations/operationPath.js";
|
|
107
|
+
export * from "./decorators/operations/partial.js";
|
|
108
|
+
export * from "./decorators/operations/path.js";
|
|
109
|
+
export * from "./decorators/operations/produces.js";
|
|
110
|
+
export * from "./decorators/operations/publish.js";
|
|
111
|
+
export * from "./decorators/operations/redirect.js";
|
|
112
|
+
export * from "./decorators/operations/returns.js";
|
|
113
|
+
export * from "./decorators/operations/route.js";
|
|
114
|
+
export * from "./decorators/operations/security.js";
|
|
115
|
+
export * from "./decorators/operations/status.js";
|
|
116
|
+
export * from "./decorators/operations/subscribe.js";
|
|
117
|
+
export * from "./decorators/operations/summary.js";
|
|
118
|
+
export * from "./decorators/operations/tags.js";
|
|
119
|
+
export * from "./decorators/operations/view.js";
|
|
120
|
+
export * from "./domain/DecoratorContext.js";
|
|
121
|
+
export * from "./domain/JsonAliasMap.js";
|
|
122
|
+
export * from "./domain/JsonClassStore.js";
|
|
123
|
+
export * from "./domain/JsonDiscriminator.js";
|
|
124
|
+
export * from "./domain/JsonEntityStore.js";
|
|
125
|
+
export * from "./domain/JsonFormatTypes.js";
|
|
126
|
+
export * from "./domain/JsonLazyRef.js";
|
|
127
|
+
export * from "./domain/JsonMap.js";
|
|
128
|
+
export * from "./domain/JsonMedia.js";
|
|
129
|
+
export * from "./domain/JsonMethodStore.js";
|
|
130
|
+
export * from "./domain/JsonOperation.js";
|
|
131
|
+
export * from "./domain/JsonOperationPathsMap.js";
|
|
132
|
+
export * from "./domain/JsonOperationRoute.js";
|
|
133
|
+
export * from "./domain/JsonParameter.js";
|
|
134
|
+
export * from "./domain/JsonParameterStore.js";
|
|
135
|
+
export * from "./domain/JsonParameterTypes.js";
|
|
136
|
+
export * from "./domain/JsonPropertyStore.js";
|
|
137
|
+
export * from "./domain/JsonRequestBody.js";
|
|
138
|
+
export * from "./domain/JsonResponse.js";
|
|
139
|
+
export * from "./domain/JsonSchema.js";
|
|
140
|
+
export * from "./domain/SpecTypes.js";
|
|
141
|
+
export * from "./hooks/alterIgnore.js";
|
|
142
|
+
export * from "./hooks/alterOneOf.js";
|
|
143
|
+
export * from "./hooks/alterRequiredGroups.js";
|
|
144
|
+
export * from "./interfaces/IgnoreCallback.js";
|
|
145
|
+
export * from "./interfaces/JsonHookContext.js";
|
|
146
|
+
export * from "./interfaces/JsonOpenSpec.js";
|
|
147
|
+
export * from "./interfaces/JsonSchemaOptions.js";
|
|
148
|
+
export * from "./registries/enumRegistries.js";
|
|
149
|
+
export * from "./registries/JsonSchemaMapperContainer.js";
|
|
150
|
+
export * from "./utils/buildPath.js";
|
|
151
|
+
export * from "./utils/concatParameters.js";
|
|
152
|
+
export * from "./utils/concatPath.js";
|
|
153
|
+
export * from "./utils/defineStatusModel.js";
|
|
154
|
+
export * from "./utils/from.js";
|
|
155
|
+
export * from "./utils/generateSpec.js";
|
|
156
|
+
export * from "./utils/generics.js";
|
|
157
|
+
export * from "./utils/getComputedType.js";
|
|
158
|
+
export * from "./utils/getInheritedStores.js";
|
|
159
|
+
export * from "./utils/getJsonEntityStore.js";
|
|
160
|
+
export * from "./utils/getJsonPathParameters.js";
|
|
161
|
+
export * from "./utils/getJsonSchema.js";
|
|
162
|
+
export * from "./utils/getJsonType.js";
|
|
163
|
+
export * from "./utils/getOperationsRoutes.js";
|
|
164
|
+
export * from "./utils/getOperationsStores.js";
|
|
165
|
+
export * from "./utils/getPropertiesStores.js";
|
|
166
|
+
export * from "./utils/getSpec.js";
|
|
167
|
+
export * from "./utils/getSpecType.js";
|
|
168
|
+
export * from "./utils/isSuccessStatus.js";
|
|
169
|
+
export * from "./utils/mapHeaders.js";
|
|
170
|
+
export * from "./utils/mapOpenSpec.js";
|
|
171
|
+
export * from "./utils/mapOpenSpec2.js";
|
|
172
|
+
export * from "./utils/mapOpenSpec3.js";
|
|
173
|
+
export * from "./utils/mapOpenSpecInfo.js";
|
|
174
|
+
export * from "./utils/mapOperationOptions.js";
|
|
175
|
+
export * from "./utils/matchGroups.js";
|
|
176
|
+
export * from "./utils/mergeSpec.js";
|
|
177
|
+
export * from "./utils/operationIdFormatter.js";
|
|
178
|
+
export * from "./utils/ref.js";
|
|
179
|
+
export * from "./utils/removeHiddenOperation.js";
|
|
180
|
+
export * from "./utils/serializeEnumValues.js";
|
|
181
|
+
export * from "./utils/somethingOf.js";
|
|
182
|
+
export * from "./utils/toJsonMapCollection.js";
|
|
183
|
+
export * from "./utils/toJsonRegex.js";
|
|
184
|
+
export * from "./utils/transformToOS2.js";
|
|
185
|
+
export * from "./utils/withErrorMsg.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace TsED {
|
|
3
|
+
interface JsonHookContext {}
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface JsonHookContext extends TsED.JsonHookContext {
|
|
8
|
+
/**
|
|
9
|
+
* The current instance used by serializer function
|
|
10
|
+
*/
|
|
11
|
+
self: any;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
groups?: string[] | false;
|
|
16
|
+
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {SpecTypes} from "../domain/SpecTypes.js";
|
|
2
|
+
|
|
3
|
+
export interface JsonSchemaOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Map properties with the alias name. By default, false
|
|
6
|
+
*/
|
|
7
|
+
useAlias?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Reference to components Object.
|
|
10
|
+
*/
|
|
11
|
+
components?: Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Define Spec types level
|
|
14
|
+
*/
|
|
15
|
+
specType?: SpecTypes;
|
|
16
|
+
/**
|
|
17
|
+
* Define a groups restriction to generate the JsonSchema.
|
|
18
|
+
* Set false to disable groups.
|
|
19
|
+
*/
|
|
20
|
+
groups?: string[] | false;
|
|
21
|
+
/**
|
|
22
|
+
* Set the postfix groups name for generated model and ref.
|
|
23
|
+
*/
|
|
24
|
+
groupsName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate custom keys when SpecType is JSON.
|
|
27
|
+
*/
|
|
28
|
+
customKeys?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Inline enums when enum instead of using $ref.
|
|
31
|
+
*/
|
|
32
|
+
inlineEnums?: boolean;
|
|
33
|
+
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {SpecTypes} from "../domain/SpecTypes.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface JsonSchemaMapper {
|
|
7
|
+
(...args: any[]): any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
const JsonSchemaMappersContainer: Map<string, JsonSchemaMapper> = new Map();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
export function registerJsonSchemaMapper(type: string, mapper: JsonSchemaMapper, spec?: SpecTypes) {
|
|
19
|
+
return JsonSchemaMappersContainer.set(spec ? `${spec}:${type}` : type, mapper);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
export function getJsonSchemaMapper(type: string, options: any): JsonSchemaMapper {
|
|
26
|
+
const mapper = JsonSchemaMappersContainer.get(`${options?.specType}:${type}`)! || JsonSchemaMappersContainer.get(type)!;
|
|
27
|
+
|
|
28
|
+
if (mapper) {
|
|
29
|
+
return mapper;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// istanbul ignore next
|
|
33
|
+
throw new Error(`JsonSchema ${type} mapper doesn't exists`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
export function execMapper(type: string, args: any[], options: any, parent?: any): any {
|
|
40
|
+
return getJsonSchemaMapper(type, options)(...args, options, parent);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function hasMapper(type: string) {
|
|
44
|
+
return JsonSchemaMappersContainer.has(type);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function oneOfMapper(types: string[], options: any): string {
|
|
48
|
+
return (
|
|
49
|
+
types.find((type) => JsonSchemaMappersContainer.has(`${options?.specType}:${type}`)) ||
|
|
50
|
+
types.find((type) => JsonSchemaMappersContainer.has(type))!
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`generateSpec() > OS 3.0.1 > should generate spec with sorted paths 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"info": {
|
|
6
|
+
"title": "Api documentation",
|
|
7
|
+
"version": "1.0.0",
|
|
8
|
+
},
|
|
9
|
+
"openapi": "3.0.1",
|
|
10
|
+
"paths": {
|
|
11
|
+
"/rest/controller1": {
|
|
12
|
+
"get": {
|
|
13
|
+
"operationId": "controller1Method",
|
|
14
|
+
"parameters": [],
|
|
15
|
+
"responses": {
|
|
16
|
+
"200": {
|
|
17
|
+
"description": "Success",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
"tags": [
|
|
21
|
+
"Controller1",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
"/rest/controller1/test": {
|
|
26
|
+
"post": {
|
|
27
|
+
"operationId": "controller1Method5",
|
|
28
|
+
"parameters": [],
|
|
29
|
+
"responses": {
|
|
30
|
+
"200": {
|
|
31
|
+
"description": "Success",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"tags": [
|
|
35
|
+
"Controller1",
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
"/rest/controller1/{id}": {
|
|
40
|
+
"get": {
|
|
41
|
+
"operationId": "controller1MethodById",
|
|
42
|
+
"parameters": [
|
|
43
|
+
{
|
|
44
|
+
"in": "path",
|
|
45
|
+
"name": "id",
|
|
46
|
+
"required": true,
|
|
47
|
+
"schema": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
"responses": {
|
|
53
|
+
"200": {
|
|
54
|
+
"description": "Success",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
"tags": [
|
|
58
|
+
"Controller1",
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
"/rest/controller2": {
|
|
63
|
+
"get": {
|
|
64
|
+
"operationId": "controller2Method",
|
|
65
|
+
"parameters": [],
|
|
66
|
+
"responses": {
|
|
67
|
+
"200": {
|
|
68
|
+
"description": "Success",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
"tags": [
|
|
72
|
+
"Controller2",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
"/rest/controller2/{id}": {
|
|
77
|
+
"get": {
|
|
78
|
+
"operationId": "controller2MethodById",
|
|
79
|
+
"parameters": [
|
|
80
|
+
{
|
|
81
|
+
"in": "path",
|
|
82
|
+
"name": "id",
|
|
83
|
+
"required": true,
|
|
84
|
+
"schema": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
"responses": {
|
|
90
|
+
"200": {
|
|
91
|
+
"description": "Success",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
"tags": [
|
|
95
|
+
"Controller2",
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
"tags": [
|
|
101
|
+
{
|
|
102
|
+
"name": "Controller2",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "Controller1",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
*/
|
|
4
|
+
export function concatParameters(parameters: any[], operation: any) {
|
|
5
|
+
return parameters
|
|
6
|
+
.map((param) => {
|
|
7
|
+
const f = operation.parameters.find((p: any) => p.in === param.in && p.name === param.name);
|
|
8
|
+
|
|
9
|
+
return f || param;
|
|
10
|
+
})
|
|
11
|
+
.concat(...operation.parameters.filter((param: any) => param.in !== "path"));
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {concatPath} from "./concatPath.js";
|
|
2
|
+
|
|
3
|
+
describe("concatPath", () => {
|
|
4
|
+
it("should return path", () => {
|
|
5
|
+
expect(concatPath("/controllers/", "/path")).toEqual("/controllers/path");
|
|
6
|
+
expect(concatPath("/controllers", "/path")).toEqual("/controllers/path");
|
|
7
|
+
expect(concatPath("/controllers/", "path")).toEqual("/controllers/path");
|
|
8
|
+
expect(concatPath(undefined, "/path")).toEqual("/path");
|
|
9
|
+
expect(concatPath("/controllers/", undefined)).toEqual("/controllers");
|
|
10
|
+
expect(concatPath("/", "/:id")).toEqual("/:id");
|
|
11
|
+
expect(concatPath("/", "/")).toEqual("/");
|
|
12
|
+
expect(concatPath("/", undefined)).toEqual("/");
|
|
13
|
+
expect(concatPath(undefined, "/")).toEqual("/");
|
|
14
|
+
expect(concatPath("tests/", "/test")).toEqual("tests/test");
|
|
15
|
+
});
|
|
16
|
+
it("should concat regexp", () => {
|
|
17
|
+
expect(concatPath(/\/(.*)/, /\/test(.*)/).source).toEqual("\\/(.*)\\/test(.*)");
|
|
18
|
+
expect(concatPath(undefined, /\/test(.*)/).source).toEqual("\\/test(.*)");
|
|
19
|
+
expect(concatPath(/\/(.*)/, undefined).source).toEqual("\\/(.*)");
|
|
20
|
+
expect(concatPath(/\/(.*)/, "/test").source).toEqual("\\/(.*)\\/test");
|
|
21
|
+
expect(concatPath("/test", /\/test(.*)/).source).toEqual("\\/test\\/test(.*)");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function concatPath(basePath: string | undefined | RegExp, path: string | undefined | RegExp): any {
|
|
2
|
+
if (basePath instanceof RegExp || path instanceof RegExp) {
|
|
3
|
+
if (!basePath) {
|
|
4
|
+
return path;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (!path) {
|
|
8
|
+
return basePath;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const r1 = basePath instanceof RegExp ? basePath : new RegExp(basePath, "gi");
|
|
12
|
+
const r2 = path instanceof RegExp ? path : new RegExp(path, "gi");
|
|
13
|
+
|
|
14
|
+
return new RegExp(r1.source + r2.source, (r1.global ? "g" : "") + (r1.ignoreCase ? "i" : "") + (r1.multiline ? "m" : ""));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (basePath && path && basePath.endsWith("/") && path.startsWith("/")) {
|
|
18
|
+
path = path.slice(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = (basePath || "") + (path || "");
|
|
22
|
+
|
|
23
|
+
return result.endsWith("/") && result.length > 1 ? result.slice(0, -1) : result;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {Type} from "@tsed/core";
|
|
2
|
+
|
|
3
|
+
const statusesModel: Map<number, Type<any>> = new Map();
|
|
4
|
+
|
|
5
|
+
export function defineStatusModel(status: number, model: Type<any>) {
|
|
6
|
+
statusesModel.set(status, model);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getStatusModel(status: number) {
|
|
10
|
+
return statusesModel.get(status);
|
|
11
|
+
}
|