@tsed/schema 8.34.0 → 8.36.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/lib/esm/compat.js +8 -0
- package/lib/esm/components/index.js +37 -27
- package/lib/esm/components/{default → mappers/default}/anyMapper.js +5 -5
- package/lib/esm/components/{default → mappers/default}/classMapper.js +5 -5
- package/lib/esm/components/{default → mappers/default}/discriminatorMappingMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/enumsMapper.js +2 -2
- package/lib/esm/components/{default → mappers/default}/genericsMapper.js +7 -6
- package/lib/esm/components/{default → mappers/default}/inheritedClassMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/lazyRefMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/mapMapper.js +2 -2
- package/lib/esm/components/{default → mappers/default}/nextMapper.js +16 -16
- package/lib/esm/components/{default → mappers/default}/nullableMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/objectMapper.js +4 -4
- package/lib/esm/components/mappers/default/ofMapper.js +9 -0
- package/lib/esm/components/{default → mappers/default}/requiredMapper.js +3 -3
- package/lib/esm/components/{default → mappers/default}/schemaMapper.js +11 -6
- package/lib/esm/components/mappers/open-spec/discriminatorMappingMapper.js +8 -0
- package/lib/esm/components/mappers/open-spec/enumsMapper.js +12 -0
- package/lib/esm/components/{open-spec → mappers/open-spec}/generate.js +3 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/nullableMapper.js +3 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInFilesMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInParameterMapper.js +3 -3
- package/lib/esm/components/mappers/open-spec/operationInParametersMapper.js +5 -0
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationInQueryMapper.js +3 -3
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationMapper.js +4 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationMediaMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationRequestBodyMapper.js +4 -4
- package/lib/esm/components/{open-spec → mappers/open-spec}/operationResponseMapper.js +2 -2
- package/lib/esm/components/{open-spec → mappers/open-spec}/pathsMapper.js +10 -10
- package/lib/esm/{domain → components/stores}/JsonClassStore.js +8 -13
- package/lib/esm/{domain → components/stores}/JsonMethodStore.js +33 -28
- package/lib/esm/{domain → components/stores}/JsonParameterStore.js +14 -18
- package/lib/esm/{domain → components/stores}/JsonPropertyStore.js +15 -18
- package/lib/esm/components/types/arrayType.js +15 -0
- package/lib/esm/components/types/classType.js +8 -0
- package/lib/esm/components/types/genericType.js +8 -0
- package/lib/esm/components/types/mapType.js +15 -0
- package/lib/esm/components/types/primitiveType.js +21 -0
- package/lib/esm/components/types/setType.js +12 -0
- package/lib/esm/decorators/class/discriminatorValue.js +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +2 -2
- package/lib/esm/decorators/collections/maxItems.js +1 -1
- package/lib/esm/decorators/collections/maxProperties.js +1 -1
- package/lib/esm/decorators/collections/minItems.js +1 -1
- package/lib/esm/decorators/collections/minProperties.js +1 -1
- package/lib/esm/decorators/collections/uniqueItems.js +1 -1
- package/lib/esm/decorators/common/defaultMsg.js +1 -1
- package/lib/esm/decorators/common/discriminatorKey.js +1 -1
- package/lib/esm/decorators/common/enum.js +1 -1
- package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
- package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
- package/lib/esm/decorators/common/format.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js +2 -2
- package/lib/esm/decorators/common/maxLength.js +1 -1
- package/lib/esm/decorators/common/maximum.js +1 -1
- package/lib/esm/decorators/common/minLength.js +1 -1
- package/lib/esm/decorators/common/minimum.js +1 -1
- package/lib/esm/decorators/common/multipleOf.js +1 -1
- package/lib/esm/decorators/common/name.js +1 -1
- package/lib/esm/decorators/common/nullable.js +2 -2
- package/lib/esm/decorators/common/pattern.js +1 -1
- package/lib/esm/decorators/common/required.js +1 -1
- package/lib/esm/decorators/common/requiredGroups.js +1 -1
- package/lib/esm/decorators/common/typeError.js +1 -1
- package/lib/esm/decorators/config/jsonEntityComponent.js +3 -2
- package/lib/esm/decorators/generics/genericOf.js +2 -2
- package/lib/esm/decorators/generics/generics.js +2 -3
- package/lib/esm/decorators/operations/consumes.js +1 -1
- package/lib/esm/decorators/operations/deprecated.js +1 -1
- package/lib/esm/decorators/operations/header.js +1 -1
- package/lib/esm/decorators/operations/in.js +5 -6
- package/lib/esm/decorators/operations/inFile.js +2 -2
- package/lib/esm/decorators/operations/operation.js +1 -1
- package/lib/esm/decorators/operations/produces.js +1 -1
- package/lib/esm/decorators/operations/publish.js +1 -1
- package/lib/esm/decorators/operations/returns.js +4 -4
- package/lib/esm/decorators/operations/route.js +1 -1
- package/lib/esm/decorators/operations/security.js +1 -1
- package/lib/esm/decorators/operations/subscribe.js +1 -1
- package/lib/esm/decorators/operations/tags.js +1 -1
- package/lib/esm/domain/DecoratorContext.js +2 -2
- package/lib/esm/domain/JsonEntityStore.js +7 -41
- package/lib/esm/domain/JsonLazyRef.js +1 -1
- package/lib/esm/domain/JsonMap.js +1 -1
- package/lib/esm/domain/JsonOperation.js +1 -1
- package/lib/esm/domain/JsonParameter.js +3 -3
- package/lib/esm/domain/JsonRequestBody.js +1 -1
- package/lib/esm/domain/JsonResponse.js +2 -2
- package/lib/esm/domain/JsonSchema.js +92 -137
- package/lib/esm/domain/index.js +26 -0
- package/lib/esm/fn/compile.js +82 -0
- package/lib/esm/fn/enums.js +1 -1
- package/lib/esm/fn/from.js +32 -9
- package/lib/esm/fn/generic.js +9 -0
- package/lib/esm/fn/index.js +25 -4
- package/lib/esm/fn/lazyRef.js +3 -3
- package/lib/esm/fn/oas/compileSpec.js +9 -0
- package/lib/esm/{utils → fn/oas}/generateSpec.js +2 -2
- package/lib/esm/{utils → fn/oas}/getSpec.js +4 -4
- package/lib/esm/{utils → fn/oas}/getSpecType.js +1 -1
- package/lib/esm/{utils → fn/oas}/mapOpenSpec.js +1 -1
- package/lib/esm/hooks/alterOneOf.js +1 -1
- package/lib/esm/index.js +60 -48
- package/lib/esm/registries/JsonEntitiesContainer.js +38 -0
- package/lib/esm/registries/JsonSchemaMapperContainer.js +10 -1
- package/lib/esm/registries/JsonTypesContainer.js +18 -0
- package/lib/esm/utils/generics.js +15 -2
- package/lib/esm/utils/getInheritedStores.js +1 -1
- package/lib/esm/utils/getOperationsRoutes.js +3 -3
- package/lib/esm/utils/getOperationsStores.js +4 -4
- package/lib/esm/utils/getPropertiesStores.js +2 -2
- package/lib/esm/utils/inlineRefs.js +64 -0
- package/lib/esm/utils/ref.js +2 -2
- package/lib/types/compat.d.ts +17 -0
- package/lib/types/components/index.d.ts +37 -27
- package/lib/types/components/{default → mappers/default}/anyMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/classMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/discriminatorMappingMapper.d.ts +2 -2
- package/lib/types/components/mappers/default/enumsMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/genericsMapper.d.ts +2 -2
- package/lib/types/components/{default → mappers/default}/inheritedClassMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/lazyRefMapper.d.ts +3 -0
- package/lib/types/components/{default → mappers/default}/mapMapper.d.ts +1 -1
- package/lib/types/components/{default → mappers/default}/nextMapper.d.ts +2 -2
- package/lib/types/components/{default → mappers/default}/nullableMapper.d.ts +1 -1
- package/lib/types/components/{default → mappers/default}/objectMapper.d.ts +1 -1
- package/lib/types/components/mappers/default/ofMapper.d.ts +3 -0
- package/lib/types/components/mappers/default/requiredMapper.d.ts +3 -0
- package/lib/types/components/mappers/default/schemaMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/enumsMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/generate.d.ts +1 -0
- package/lib/types/components/mappers/open-spec/nullableMapper.d.ts +3 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInParameterMapper.d.ts +3 -3
- package/lib/types/components/mappers/open-spec/operationInParametersMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationMediaMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationRequestBodyMapper.d.ts +3 -0
- package/lib/types/components/mappers/open-spec/operationResponseMapper.d.ts +3 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/pathsMapper.d.ts +1 -1
- package/lib/types/{domain → components/stores}/JsonClassStore.d.ts +4 -4
- package/lib/types/{domain → components/stores}/JsonMethodStore.d.ts +33 -19
- package/lib/types/{domain → components/stores}/JsonParameterStore.d.ts +9 -5
- package/lib/types/{domain → components/stores}/JsonPropertyStore.d.ts +7 -4
- package/lib/types/components/types/arrayType.d.ts +2 -0
- package/lib/types/components/types/classType.d.ts +2 -0
- package/lib/types/components/types/genericType.d.ts +2 -0
- package/lib/types/components/types/mapType.d.ts +2 -0
- package/lib/types/components/types/primitiveType.d.ts +2 -0
- package/lib/types/components/types/setType.d.ts +2 -0
- package/lib/types/decorators/common/any.d.ts +1 -1
- package/lib/types/decorators/common/examples.d.ts +1 -1
- package/lib/types/decorators/common/format.d.ts +1 -1
- package/lib/types/decorators/common/ignore.d.ts +1 -1
- package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
- package/lib/types/decorators/config/jsonEntityComponent.d.ts +2 -1
- package/lib/types/decorators/generics/genericOf.d.ts +1 -1
- package/lib/types/decorators/operations/header.d.ts +1 -1
- package/lib/types/decorators/operations/in.d.ts +1 -2
- package/lib/types/decorators/operations/location.d.ts +1 -1
- package/lib/types/decorators/operations/redirect.d.ts +1 -1
- package/lib/types/decorators/operations/returns.d.ts +3 -3
- package/lib/types/decorators/operations/status.d.ts +1 -1
- package/lib/types/domain/Generics.d.ts +6 -0
- package/lib/types/domain/JsonEntityStore.d.ts +8 -19
- package/lib/types/domain/JsonLazyRef.d.ts +1 -1
- package/lib/types/domain/JsonMap.d.ts +1 -1
- package/lib/types/domain/JsonMedia.d.ts +1 -1
- package/lib/types/domain/JsonOperation.d.ts +2 -2
- package/lib/types/domain/JsonOperationRoute.d.ts +3 -3
- package/lib/types/domain/JsonParameter.d.ts +3 -3
- package/lib/types/domain/JsonRequestBody.d.ts +1 -1
- package/lib/types/domain/JsonResponse.d.ts +1 -1
- package/lib/types/domain/JsonSchema.d.ts +28 -22
- package/lib/types/{interfaces → domain}/JsonSchemaOptions.d.ts +20 -6
- package/lib/types/domain/__fixtures__/inspectOperationsPaths.d.ts +1 -1
- package/lib/types/domain/index.d.ts +26 -0
- package/lib/types/domain/types.d.ts +1 -1
- package/lib/types/fn/any.d.ts +1 -1
- package/lib/types/fn/boolean.d.ts +1 -1
- package/lib/types/fn/compile.d.ts +21 -0
- package/lib/types/fn/date.d.ts +3 -3
- package/lib/types/fn/email.d.ts +1 -1
- package/lib/types/fn/from.d.ts +31 -3
- package/lib/types/fn/generic.d.ts +10 -0
- package/lib/types/fn/index.d.ts +24 -3
- package/lib/types/fn/integer.d.ts +1 -1
- package/lib/types/fn/lazyRef.d.ts +1 -1
- package/lib/types/fn/number.d.ts +1 -1
- package/lib/types/fn/oas/compileSpec.d.ts +6 -0
- package/lib/types/{utils → fn/oas}/getSpec.d.ts +1 -1
- package/lib/types/{utils → fn/oas}/getSpecType.d.ts +1 -1
- package/lib/types/{utils → fn/oas}/transformToOS2.d.ts +1 -1
- package/lib/types/fn/object.d.ts +1 -1
- package/lib/types/fn/string.d.ts +1 -1
- package/lib/types/fn/uri.d.ts +1 -1
- package/lib/types/fn/url.d.ts +1 -1
- package/lib/types/hooks/alterOneOf.d.ts +1 -1
- package/lib/types/hooks/alterRequiredGroups.d.ts +1 -1
- package/lib/types/index.d.ts +60 -48
- package/lib/types/{utils/getJsonEntityStore.d.ts → registries/JsonEntitiesContainer.d.ts} +5 -10
- package/lib/types/registries/JsonSchemaMapperContainer.d.ts +7 -1
- package/lib/types/registries/JsonTypesContainer.d.ts +15 -0
- package/lib/types/registries/{enumRegistries.d.ts → enumRegistry.d.ts} +1 -1
- package/lib/types/utils/generics.d.ts +13 -5
- package/lib/types/utils/getInheritedStores.d.ts +1 -1
- package/lib/types/utils/getOperationsRoutes.d.ts +3 -3
- package/lib/types/utils/getOperationsStores.d.ts +1 -1
- package/lib/types/utils/getPropertiesStores.d.ts +1 -1
- package/lib/types/utils/inlineRefs.d.ts +7 -0
- package/lib/types/utils/mapHeaders.d.ts +1 -1
- package/lib/types/utils/operationIdFormatter.d.ts +1 -1
- package/lib/types/utils/ref.d.ts +1 -1
- package/lib/types/utils/removeHiddenOperation.d.ts +1 -1
- package/lib/types/utils/toJsonMapCollection.d.ts +1 -1
- package/package.json +18 -19
- package/lib/esm/components/default/ofMapper.js +0 -9
- package/lib/esm/components/open-spec/discriminatorMappingMapper.js +0 -6
- package/lib/esm/components/open-spec/enumsMapper.js +0 -14
- package/lib/esm/components/open-spec/operationInParametersMapper.js +0 -5
- package/lib/esm/utils/compile.js +0 -13
- package/lib/esm/utils/getJsonEntityStore.js +0 -13
- package/lib/esm/utils/getJsonSchema.js +0 -66
- package/lib/types/components/default/classMapper.d.ts +0 -3
- package/lib/types/components/default/enumsMapper.d.ts +0 -3
- package/lib/types/components/default/lazyRefMapper.d.ts +0 -3
- package/lib/types/components/default/ofMapper.d.ts +0 -3
- package/lib/types/components/default/requiredMapper.d.ts +0 -3
- package/lib/types/components/default/schemaMapper.d.ts +0 -3
- package/lib/types/components/open-spec/enumsMapper.d.ts +0 -3
- package/lib/types/components/open-spec/nullableMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationInParametersMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationMediaMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationRequestBodyMapper.d.ts +0 -3
- package/lib/types/components/open-spec/operationResponseMapper.d.ts +0 -3
- package/lib/types/utils/compile.d.ts +0 -14
- package/lib/types/utils/getJsonSchema.d.ts +0 -6
- package/lib/esm/{interfaces/IgnoreCallback.js → domain/Generics.js} +0 -0
- package/lib/esm/{interfaces/JsonHookContext.js → domain/IgnoreCallback.js} +0 -0
- package/lib/esm/{interfaces/JsonOpenSpec.js → domain/JsonHookContext.js} +0 -0
- package/lib/esm/{interfaces/JsonSchemaOptions.js → domain/JsonOpenSpec.js} +0 -0
- package/lib/{types/components/open-spec/discriminatorMappingMapper.d.ts → esm/domain/JsonSchemaOptions.js} +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpec2.js +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpec3.js +0 -0
- package/lib/esm/{utils → fn/oas}/mapOpenSpecInfo.js +0 -0
- package/lib/esm/{utils → fn/oas}/mergeSpec.js +0 -0
- package/lib/esm/{utils → fn/oas}/transformToOS2.js +0 -0
- package/lib/esm/registries/{enumRegistries.js → enumRegistry.js} +0 -0
- package/lib/types/components/{open-spec/generate.d.ts → mappers/open-spec/discriminatorMappingMapper.d.ts} +0 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInFilesMapper.d.ts +0 -0
- package/lib/types/components/{open-spec → mappers/open-spec}/operationInQueryMapper.d.ts +0 -0
- package/lib/types/{interfaces → domain}/IgnoreCallback.d.ts +0 -0
- package/lib/types/{interfaces → domain}/JsonHookContext.d.ts +0 -0
- package/lib/types/{interfaces → domain}/JsonOpenSpec.d.ts +0 -0
- package/lib/types/{utils → fn/oas}/generateSpec.d.ts +1 -1
- /package/lib/types/{utils → fn/oas}/mapOpenSpec.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpec2.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpec3.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mapOpenSpecInfo.d.ts +0 -0
- /package/lib/types/{utils → fn/oas}/mergeSpec.d.ts +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Type, ValueOf } from "@tsed/core";
|
|
2
|
-
import { Hooks } from "@tsed/hooks";
|
|
3
|
-
import type { JSONSchema7, JSONSchema7Definition, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version } from "json-schema";
|
|
4
|
-
import { VendorKeys } from "../constants/VendorKeys.js";
|
|
5
|
-
import { IgnoreCallback } from "../interfaces/IgnoreCallback.js";
|
|
6
|
-
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions.js";
|
|
7
|
-
import { type GenericsMap, GenericValue } from "../utils/generics.js";
|
|
8
1
|
import { AliasMap, AliasType } from "./JsonAliasMap.js";
|
|
2
|
+
import type { GenericValue, GenericsMap } from "./Generics.js";
|
|
3
|
+
import type { Infer, PropsToShape, SchemaKey, SchemaMerge, SchemaOmit, SchemaPartial, SchemaPick, UnionToIntersection } from "./types.js";
|
|
4
|
+
import type { JSONSchema7, JSONSchema7Definition, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version } from "json-schema";
|
|
5
|
+
import { Type, ValueOf } from "@tsed/core";
|
|
9
6
|
import { Discriminator } from "./JsonDiscriminator.js";
|
|
7
|
+
import { Hooks } from "@tsed/hooks";
|
|
8
|
+
import { IgnoreCallback } from "./IgnoreCallback.js";
|
|
10
9
|
import { JsonFormatTypes } from "./JsonFormatTypes.js";
|
|
11
10
|
import { JsonLazyRef } from "./JsonLazyRef.js";
|
|
12
|
-
import
|
|
11
|
+
import { JsonSchemaOptions } from "./JsonSchemaOptions.js";
|
|
12
|
+
import { VendorKeys } from "../constants/VendorKeys.js";
|
|
13
13
|
/**
|
|
14
14
|
* Extended JSON Schema object supporting TypeScript types and Ts.ED enhancements.
|
|
15
15
|
*
|
|
@@ -72,7 +72,7 @@ export type AnyJsonSchema<T = any> = JsonSchemaObject | JSONSchema7 | JsonSchema
|
|
|
72
72
|
* email: string;
|
|
73
73
|
* }
|
|
74
74
|
*
|
|
75
|
-
* const userSchema =
|
|
75
|
+
* const userSchema = s.from(User);
|
|
76
76
|
*
|
|
77
77
|
* // Generate JSON Schema output
|
|
78
78
|
* const jsonSchema = userSchema.toJSON();
|
|
@@ -223,22 +223,22 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
223
223
|
*
|
|
224
224
|
* ```typescript
|
|
225
225
|
* // From a class
|
|
226
|
-
* const schema1 =
|
|
226
|
+
* const schema1 = s.from(User);
|
|
227
227
|
*
|
|
228
228
|
* // From a primitive
|
|
229
|
-
* const schema2 =
|
|
229
|
+
* const schema2 = s.from(String);
|
|
230
230
|
*
|
|
231
231
|
* // From a schema object
|
|
232
|
-
* const schema3 =
|
|
232
|
+
* const schema3 = s.string().minLength(1);
|
|
233
233
|
*
|
|
234
234
|
* // From existing schema (no-op)
|
|
235
|
-
* const schema4 =
|
|
235
|
+
* const schema4 = s.from(schema1);
|
|
236
236
|
* ```
|
|
237
237
|
*
|
|
238
238
|
* @param item - The input to convert to a JsonSchema
|
|
239
239
|
* @returns A JsonSchema instance representing the input
|
|
240
|
+
* @deprecated
|
|
240
241
|
*/
|
|
241
|
-
static from(item: Partial<JsonSchemaObject> | Type<any> | JsonSchema | undefined): JsonSchema<JSONSchema7Type>;
|
|
242
242
|
static add<Keys extends keyof JsonSchema>(property: Keys, method: JsonSchema[Keys]): typeof JsonSchema;
|
|
243
243
|
/**
|
|
244
244
|
* Check if the schema has a property.
|
|
@@ -354,12 +354,16 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
354
354
|
* ```typescript
|
|
355
355
|
* // For Paginated<User>
|
|
356
356
|
* schema.genericOf([User]);
|
|
357
|
+
* schema.genericOf(User);
|
|
358
|
+
* schema.genericOf({T: [User]});
|
|
357
359
|
* ```
|
|
358
360
|
*
|
|
359
|
-
* @param generics -
|
|
361
|
+
* @param generics - Generic bindings to apply
|
|
360
362
|
* @returns This schema instance for method chaining
|
|
361
363
|
*/
|
|
362
|
-
genericOf(
|
|
364
|
+
genericOf(generics: GenericsMap): this;
|
|
365
|
+
genericOf(generic: GenericValue): this;
|
|
366
|
+
genericOf(...generics: Array<GenericValue[] | GenericValue>): this;
|
|
363
367
|
/**
|
|
364
368
|
* Mark this schema as nullable or non-nullable.
|
|
365
369
|
*
|
|
@@ -565,7 +569,7 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
565
569
|
* Set the items' schema for array/set collections
|
|
566
570
|
* @param items The schema for array/set items
|
|
567
571
|
*/
|
|
568
|
-
items<I = JSONSchema7Type>(items: JsonSchema<I> | AnyJsonSchema | AnyJsonSchema[]): JsonSchema<T extends Array<any> ? I[] : T extends Set<any> ? Set<I> : I>;
|
|
572
|
+
items<I = JSONSchema7Type>(items: JsonSchema<I> | AnyJsonSchema | AnyJsonSchema[], init?: boolean): JsonSchema<T extends Array<any> ? I[] : T extends Set<any> ? Set<I> : I>;
|
|
569
573
|
$comment(comment: string): this;
|
|
570
574
|
/**
|
|
571
575
|
* Must be a non-negative integer.
|
|
@@ -646,7 +650,7 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
646
650
|
* The default value is an empty schema that allows any value for additional properties.
|
|
647
651
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20
|
|
648
652
|
*/
|
|
649
|
-
additionalProperties<V>(additionalProperties: boolean | AnyJsonSchema | JsonSchema<V
|
|
653
|
+
additionalProperties<V>(additionalProperties: boolean | AnyJsonSchema | JsonSchema<V>, init?: boolean): JsonSchema<Map<string, V>>;
|
|
650
654
|
/**
|
|
651
655
|
* This attribute defines a schema for all properties that are not explicitly defined in an object type definition.
|
|
652
656
|
* If specified, the value MUST be a schema or a boolean.
|
|
@@ -787,7 +791,7 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
787
791
|
toObject(options?: JsonSchemaOptions): any;
|
|
788
792
|
toJSON(options?: JsonSchemaOptions): any;
|
|
789
793
|
assign(obj: Partial<JSONSchema7> | JsonSchema | Record<string, unknown>): this;
|
|
790
|
-
set(key: string, value: any): this;
|
|
794
|
+
set(key: string, value: any, force?: boolean): this;
|
|
791
795
|
/**
|
|
792
796
|
* Return the JSON type as string
|
|
793
797
|
*/
|
|
@@ -812,11 +816,13 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
|
|
|
812
816
|
getRefSchema(): JsonSchema<JSONSchema7Type> | undefined;
|
|
813
817
|
propertyKey(s: string): this;
|
|
814
818
|
getPropertyKey(): string | symbol | undefined;
|
|
815
|
-
target(target: any):
|
|
819
|
+
target(target: any): this;
|
|
816
820
|
isRequiredValue(property: string, value: any): boolean;
|
|
821
|
+
toCollection(): this;
|
|
822
|
+
unsetType(): this;
|
|
817
823
|
protected setManyOf(keyword: "oneOf" | "anyOf" | "allOf", value: (AnyJsonSchema | null)[]): this | undefined;
|
|
818
|
-
protected
|
|
819
|
-
protected
|
|
824
|
+
protected toSchema(item: any[]): JsonSchema[];
|
|
825
|
+
protected toSchema(item: any): JsonSchema;
|
|
820
826
|
protected mapGenerics(jsonSchema: unknown, generics: GenericValue[][]): GenericsMap;
|
|
821
827
|
protected mapProperties(properties: Record<string, any>): any;
|
|
822
828
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { GenericsMap } from "./Generics.js";
|
|
2
|
+
import { SpecTypes } from "./SpecTypes.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for JSON schema generation.
|
|
5
5
|
*
|
|
@@ -61,12 +61,26 @@ export interface JsonSchemaOptions {
|
|
|
61
61
|
*/
|
|
62
62
|
inlineEnums?: boolean;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* Inline resolvable local JSON Schema references in the compiled output.
|
|
65
65
|
*
|
|
66
|
-
*
|
|
67
|
-
|
|
66
|
+
* External references and circular local references are preserved.
|
|
67
|
+
*/
|
|
68
|
+
inlineRefs?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Explicit generic bindings used during schema compilation.
|
|
71
|
+
*
|
|
72
|
+
* Prefer attaching generics directly to a local schema instance with the
|
|
73
|
+
* functional API:
|
|
74
|
+
*
|
|
75
|
+
* ```typescript
|
|
76
|
+
* from(Pagination).genericOf(Product)
|
|
77
|
+
* generic(Pagination).of(Product)
|
|
78
|
+
* ```
|
|
68
79
|
*
|
|
69
|
-
*
|
|
80
|
+
* `options.generics` remains useful for low-level compilation flows where the
|
|
81
|
+
* generic bindings must be supplied externally, for example when compiling a
|
|
82
|
+
* shared class schema. When both are provided, the generics carried by the
|
|
83
|
+
* `JsonSchema` instance take precedence over `options.generics`.
|
|
70
84
|
*/
|
|
71
85
|
generics?: GenericsMap;
|
|
72
86
|
[key: string]: any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./DecoratorContext.js";
|
|
5
|
+
export * from "./Generics.js";
|
|
6
|
+
export * from "./IgnoreCallback.js";
|
|
7
|
+
export * from "./JsonAliasMap.js";
|
|
8
|
+
export * from "./JsonDiscriminator.js";
|
|
9
|
+
export * from "./JsonEntityStore.js";
|
|
10
|
+
export * from "./JsonFormatTypes.js";
|
|
11
|
+
export * from "./JsonHookContext.js";
|
|
12
|
+
export * from "./JsonLazyRef.js";
|
|
13
|
+
export * from "./JsonMap.js";
|
|
14
|
+
export * from "./JsonMedia.js";
|
|
15
|
+
export * from "./JsonOpenSpec.js";
|
|
16
|
+
export * from "./JsonOperation.js";
|
|
17
|
+
export * from "./JsonOperationPathsMap.js";
|
|
18
|
+
export * from "./JsonOperationRoute.js";
|
|
19
|
+
export * from "./JsonParameter.js";
|
|
20
|
+
export * from "./JsonParameterTypes.js";
|
|
21
|
+
export * from "./JsonRequestBody.js";
|
|
22
|
+
export * from "./JsonResponse.js";
|
|
23
|
+
export * from "./JsonSchema.js";
|
|
24
|
+
export * from "./JsonSchemaOptions.js";
|
|
25
|
+
export * from "./SpecTypes.js";
|
|
26
|
+
export * from "./types.js";
|
package/lib/types/fn/any.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
import type { Infer } from "../domain/types.js";
|
|
2
|
+
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
3
3
|
/**
|
|
4
4
|
* Declare a model with any type (By default: `integer`, `number`, `string`, `boolean`, `array`, `object`, `null`)
|
|
5
5
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "../components/index.js";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { JsonSchema } from "../domain/index.js";
|
|
4
|
+
import { JsonParameterStore } from "../components/index.js";
|
|
5
|
+
import { JsonSchemaOptions } from "../domain/JsonSchemaOptions.js";
|
|
6
|
+
/**
|
|
7
|
+
* Compile a class, parameter store, or `JsonSchema` into a plain JSON schema object.
|
|
8
|
+
*
|
|
9
|
+
* This is an alias of `getJsonSchema(...)`.
|
|
10
|
+
*
|
|
11
|
+
* @param model Class, parameter store, or `JsonSchema` to compile.
|
|
12
|
+
* @param options JSON schema generation options.
|
|
13
|
+
* @returns Compiled JSON schema object.
|
|
14
|
+
*/
|
|
15
|
+
export declare function compile(model: Type<any> | JsonParameterStore | JsonSchema<any>, options?: JsonSchemaOptions): any;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use s.compile() instead
|
|
18
|
+
* @param model
|
|
19
|
+
* @param options
|
|
20
|
+
*/
|
|
21
|
+
export declare const getJsonSchema: typeof compile;
|
package/lib/types/fn/date.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @schemaFunctional
|
|
7
7
|
*/
|
|
8
|
-
export declare function date(): import("
|
|
8
|
+
export declare function date(): import("@tsed/schema").JsonSchema<Date>;
|
|
9
9
|
/**
|
|
10
10
|
* Declare a new string model with `format: datetime`.
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ export declare function date(): import("../index.js").JsonSchema<Date>;
|
|
|
13
13
|
*
|
|
14
14
|
* @schemaFunctional
|
|
15
15
|
*/
|
|
16
|
-
export declare function datetime(): import("
|
|
16
|
+
export declare function datetime(): import("@tsed/schema").JsonSchema<Date>;
|
|
17
17
|
/**
|
|
18
18
|
* Declare a new string model with `format: time`.
|
|
19
19
|
*
|
|
@@ -21,4 +21,4 @@ export declare function datetime(): import("../index.js").JsonSchema<Date>;
|
|
|
21
21
|
*
|
|
22
22
|
* @schemaFunctional
|
|
23
23
|
*/
|
|
24
|
-
export declare function time(): import("
|
|
24
|
+
export declare function time(): import("@tsed/schema").JsonSchema<Date>;
|
package/lib/types/fn/email.d.ts
CHANGED
package/lib/types/fn/from.d.ts
CHANGED
|
@@ -1,16 +1,44 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import { JsonSchema } from "../domain/JsonSchema.js";
|
|
3
2
|
import type { CtorToType } from "../domain/types.js";
|
|
3
|
+
import { JsonSchema } from "../domain/JsonSchema.js";
|
|
4
4
|
/**
|
|
5
|
-
* Create a new
|
|
5
|
+
* Create a new local schema instance from the given type.
|
|
6
|
+
*
|
|
7
|
+
* When the input is a class, `from()` returns a cloned `JsonSchema` that can be
|
|
8
|
+
* composed safely without mutating the schema stored on the class metadata.
|
|
9
|
+
* This makes `from()` the functional entry point for schema composition.
|
|
10
|
+
*
|
|
11
|
+
* Use @@get@@ when you intentionally need the shared class schema in order to
|
|
12
|
+
* patch or extend the metadata attached to a class definition.
|
|
6
13
|
*
|
|
7
14
|
* ```typescript
|
|
8
15
|
* from(String)
|
|
16
|
+
* from(UserModel).description("Local description")
|
|
9
17
|
* ```
|
|
10
18
|
*
|
|
11
|
-
*
|
|
19
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
12
20
|
*
|
|
13
21
|
* @schemaFunctional
|
|
14
22
|
*/
|
|
15
23
|
export declare function from<TC extends Type<any> = Type<any>>(): JsonSchema<CtorToType<ObjectConstructor>>;
|
|
16
24
|
export declare function from<TC extends Type<any> = Type<any>>(type?: TC): JsonSchema<CtorToType<TC>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the shared schema instance attached to a class.
|
|
27
|
+
*
|
|
28
|
+
* Contrary to @@from@@, `get()` returns the schema stored in the class metadata.
|
|
29
|
+
* Mutating the returned instance updates the class-level schema definition and
|
|
30
|
+
* therefore affects every consumer of that class schema.
|
|
31
|
+
*
|
|
32
|
+
* This helper is intended for low-level or internal patching scenarios where the
|
|
33
|
+
* source schema must be updated in place.
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* get(UserModel).properties({
|
|
37
|
+
* name: string()
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param type The class owning the shared schema metadata.
|
|
42
|
+
* @returns The shared `JsonSchema` instance for the class.
|
|
43
|
+
*/
|
|
44
|
+
export declare function get(type: Type<any>): JsonSchema<import("json-schema").JSONSchema7Type>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GenericValue, type GenericsMap } from "../domain/Generics.js";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { from } from "./from.js";
|
|
4
|
+
export declare function generic(type?: Type<any>): {
|
|
5
|
+
of: {
|
|
6
|
+
(generics: GenericsMap): ReturnType<typeof from>;
|
|
7
|
+
(generic: GenericValue): ReturnType<typeof from>;
|
|
8
|
+
(...generics: Array<GenericValue[] | GenericValue>): ReturnType<typeof from>;
|
|
9
|
+
};
|
|
10
|
+
};
|
package/lib/types/fn/index.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { array, map, record, set } from "./collection.js";
|
|
2
|
+
import { date, datetime, time } from "./date.js";
|
|
3
|
+
import { from, get } from "./from.js";
|
|
4
|
+
import { getJsonEntityStore, getJsonMethodStore } from "../registries/JsonEntitiesContainer.js";
|
|
1
5
|
import type { Infer } from "../domain/types.js";
|
|
2
6
|
import { allOf } from "./allOf.js";
|
|
3
7
|
import { any } from "./any.js";
|
|
4
8
|
import { anyOf } from "./anyOf.js";
|
|
5
9
|
import { boolean } from "./boolean.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
10
|
+
import { compile } from "./compile.js";
|
|
11
|
+
import { compileSpec } from "./oas/compileSpec.js";
|
|
8
12
|
import { email } from "./email.js";
|
|
9
13
|
import { enums } from "./enums.js";
|
|
10
|
-
import {
|
|
14
|
+
import { generic } from "./generic.js";
|
|
11
15
|
import { integer } from "./integer.js";
|
|
12
16
|
import { lazyRef } from "./lazyRef.js";
|
|
17
|
+
import { mergeSchema } from "../utils/mergeSchema.js";
|
|
18
|
+
import { mergeSpec } from "./oas/mergeSpec.js";
|
|
13
19
|
import { number } from "./number.js";
|
|
14
20
|
import { object } from "./object.js";
|
|
15
21
|
import { oneOf } from "./oneOf.js";
|
|
@@ -45,6 +51,21 @@ export declare const s: {
|
|
|
45
51
|
readonly string: typeof string;
|
|
46
52
|
readonly uri: typeof uri;
|
|
47
53
|
readonly url: typeof url;
|
|
54
|
+
readonly generic: typeof generic;
|
|
55
|
+
readonly get: typeof get;
|
|
56
|
+
readonly store: typeof getJsonEntityStore & {
|
|
57
|
+
get: typeof getJsonEntityStore;
|
|
58
|
+
method: typeof getJsonMethodStore;
|
|
59
|
+
};
|
|
60
|
+
readonly schema: {
|
|
61
|
+
readonly compile: typeof compile;
|
|
62
|
+
readonly merge: typeof mergeSchema;
|
|
63
|
+
};
|
|
64
|
+
readonly compile: typeof compile;
|
|
65
|
+
readonly oas: typeof compileSpec & {
|
|
66
|
+
compile: typeof compileSpec;
|
|
67
|
+
merge: typeof mergeSpec;
|
|
68
|
+
};
|
|
48
69
|
};
|
|
49
70
|
export declare namespace s {
|
|
50
71
|
type infer<S> = Infer<S>;
|
package/lib/types/fn/number.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type GenerateSpecOptions } from "./generateSpec.js";
|
|
2
|
+
import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
|
|
3
|
+
import { type SpecSerializerOptions } from "./getSpec.js";
|
|
4
|
+
import { Type } from "@tsed/core";
|
|
5
|
+
export declare function compileSpec(model: Type<any>, options?: SpecSerializerOptions): Partial<OpenSpec3>;
|
|
6
|
+
export declare function compileSpec(options: GenerateSpecOptions): OpenSpec2 | OpenSpec3;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { JsonSchemaOptions } from "../../domain/JsonSchemaOptions.js";
|
|
2
3
|
import { OpenSpec3 } from "@tsed/openspec";
|
|
3
|
-
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions.js";
|
|
4
4
|
export type JsonTokenOptions = ({
|
|
5
5
|
token: Type<any>;
|
|
6
6
|
} & Partial<SpecSerializerOptions>)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type OS2Security, OS3Operation, OpenSpec2, OpenSpec3 } from "@tsed/openspec";
|
|
2
2
|
export declare function transformSecurity(securitySchemes: any): Record<string, OS2Security>;
|
|
3
3
|
export declare function transformInformation(server: any): {
|
|
4
4
|
host: string | undefined;
|
package/lib/types/fn/object.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ import { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
17
17
|
* @returns A new object model with the specified properties
|
|
18
18
|
* @schemaFunctional
|
|
19
19
|
*/
|
|
20
|
-
export declare function object<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(properties?: P): JsonSchema<import("
|
|
20
|
+
export declare function object<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(properties?: P): JsonSchema<import("@tsed/schema").PropsToShape<P>>;
|
package/lib/types/fn/string.d.ts
CHANGED
package/lib/types/fn/uri.d.ts
CHANGED
package/lib/types/fn/url.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
|
-
import type { JsonSchemaOptions } from "../
|
|
2
|
+
import type { JsonSchemaOptions } from "../domain/JsonSchemaOptions.js";
|
|
3
3
|
export declare function alterOneOf(obj: any, schema: JsonSchema, options: JsonSchemaOptions): any;
|