@tsed/schema 7.86.3 → 7.87.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/browser/schema.umd.min.js +1 -1
- package/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/components/default/anyMapper.js +1 -2
- package/lib/cjs/components/default/anyMapper.js.map +1 -1
- package/lib/cjs/components/default/classMapper.js +2 -22
- package/lib/cjs/components/default/classMapper.js.map +1 -1
- package/lib/cjs/components/default/discriminatorMappingMapper.js.map +1 -1
- package/lib/cjs/components/default/genericsMapper.js +61 -47
- package/lib/cjs/components/default/genericsMapper.js.map +1 -1
- package/lib/cjs/components/default/inheritedClassMapper.js.map +1 -1
- package/lib/cjs/components/default/lazyRefMapper.js +1 -2
- package/lib/cjs/components/default/lazyRefMapper.js.map +1 -1
- package/lib/cjs/components/default/mapMapper.js +0 -2
- package/lib/cjs/components/default/mapMapper.js.map +1 -1
- package/lib/cjs/components/default/nextMapper.js +80 -0
- package/lib/cjs/components/default/nextMapper.js.map +1 -0
- package/lib/cjs/components/default/nullableMapper.js.map +1 -1
- package/lib/cjs/components/default/objectMapper.js +8 -3
- package/lib/cjs/components/default/objectMapper.js.map +1 -1
- package/lib/cjs/components/default/ofMapper.js +2 -5
- package/lib/cjs/components/default/ofMapper.js.map +1 -1
- package/lib/cjs/components/default/requiredMapper.js +2 -2
- package/lib/cjs/components/default/requiredMapper.js.map +1 -1
- package/lib/cjs/components/default/schemaMapper.js +6 -7
- package/lib/cjs/components/default/schemaMapper.js.map +1 -1
- package/lib/cjs/components/index.js +1 -7
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/open-spec/enumsMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/generate.js.map +1 -1
- package/lib/cjs/components/open-spec/nullableMapper.js +5 -1
- package/lib/cjs/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/operationInFilesMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/operationInParameterMapper.js +3 -7
- package/lib/cjs/components/open-spec/operationInParameterMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/operationInQueryMapper.js +21 -16
- package/lib/cjs/components/open-spec/operationInQueryMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/operationMediaMapper.js +5 -2
- package/lib/cjs/components/open-spec/operationMediaMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/operationRequestBodyMapper.js +4 -3
- package/lib/cjs/components/open-spec/operationRequestBodyMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/pathsMapper.js +1 -0
- package/lib/cjs/components/open-spec/pathsMapper.js.map +1 -1
- package/lib/cjs/constants/VendorKeys.js +15 -0
- package/lib/cjs/constants/VendorKeys.js.map +1 -0
- package/lib/cjs/constants/httpStatusMessages.js +1 -1
- package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
- package/lib/cjs/decorators/class/children.js.map +1 -1
- package/lib/cjs/decorators/collections/collectionOf.js +29 -0
- package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
- package/lib/cjs/decorators/common/allow.js.map +1 -1
- package/lib/cjs/decorators/common/any.js.map +1 -1
- package/lib/cjs/decorators/common/defaultMsg.js.map +1 -1
- package/lib/cjs/decorators/common/description.js +8 -11
- package/lib/cjs/decorators/common/description.js.map +1 -1
- package/lib/cjs/decorators/common/discriminatorKey.js +1 -1
- package/lib/cjs/decorators/common/discriminatorKey.js.map +1 -1
- package/lib/cjs/decorators/common/enum.js.map +1 -1
- package/lib/cjs/decorators/common/examples.js.map +1 -1
- package/lib/cjs/decorators/common/format.js.map +1 -1
- package/lib/cjs/decorators/common/forwardGroups.js +1 -1
- package/lib/cjs/decorators/common/forwardGroups.js.map +1 -1
- package/lib/cjs/decorators/common/groups.js +15 -26
- package/lib/cjs/decorators/common/groups.js.map +1 -1
- package/lib/cjs/decorators/common/integer.js.map +1 -1
- package/lib/cjs/decorators/common/oneOf.js +1 -2
- package/lib/cjs/decorators/common/oneOf.js.map +1 -1
- package/lib/cjs/decorators/common/optional.js.map +1 -1
- package/lib/cjs/decorators/config/jsonEntityComponent.js.map +1 -1
- package/lib/cjs/decorators/generics/genericOf.js +7 -16
- package/lib/cjs/decorators/generics/genericOf.js.map +1 -1
- package/lib/cjs/decorators/generics/generics.js +3 -3
- package/lib/cjs/decorators/generics/generics.js.map +1 -1
- package/lib/cjs/decorators/operations/acceptMime.js.map +1 -1
- package/lib/cjs/decorators/operations/consumes.js.map +1 -1
- package/lib/cjs/decorators/operations/deprecated.js.map +1 -1
- package/lib/cjs/decorators/operations/header.js.map +1 -1
- package/lib/cjs/decorators/operations/in.js.map +1 -1
- package/lib/cjs/decorators/operations/inFile.js +2 -2
- package/lib/cjs/decorators/operations/inFile.js.map +1 -1
- package/lib/cjs/decorators/operations/operation.js +5 -1
- package/lib/cjs/decorators/operations/operation.js.map +1 -1
- package/lib/cjs/decorators/operations/operationId.js.map +1 -1
- package/lib/cjs/decorators/operations/operationPath.js +1 -1
- package/lib/cjs/decorators/operations/operationPath.js.map +1 -1
- package/lib/cjs/decorators/operations/path.js.map +1 -1
- package/lib/cjs/decorators/operations/produces.js.map +1 -1
- package/lib/cjs/decorators/operations/redirect.js +1 -1
- package/lib/cjs/decorators/operations/redirect.js.map +1 -1
- package/lib/cjs/decorators/operations/returns.js +39 -62
- package/lib/cjs/decorators/operations/returns.js.map +1 -1
- package/lib/cjs/decorators/operations/security.js.map +1 -1
- package/lib/cjs/decorators/operations/status.js.map +1 -1
- package/lib/cjs/decorators/operations/summary.js.map +1 -1
- package/lib/cjs/decorators/operations/tags.js +10 -1
- package/lib/cjs/decorators/operations/tags.js.map +1 -1
- package/lib/cjs/domain/DecoratorContext.js.map +1 -1
- package/lib/cjs/domain/JsonClassStore.js +1 -1
- package/lib/cjs/domain/JsonClassStore.js.map +1 -1
- package/lib/cjs/domain/JsonEntityStore.js +40 -35
- package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
- package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
- package/lib/cjs/domain/JsonMap.js.map +1 -1
- package/lib/cjs/domain/JsonMedia.js +27 -6
- package/lib/cjs/domain/JsonMedia.js.map +1 -1
- package/lib/cjs/domain/JsonMethodStore.js +27 -8
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/domain/JsonOperation.js +36 -8
- package/lib/cjs/domain/JsonOperation.js.map +1 -1
- package/lib/cjs/domain/JsonParameter.js +20 -5
- package/lib/cjs/domain/JsonParameter.js.map +1 -1
- package/lib/cjs/domain/JsonParameterStore.js +15 -25
- package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
- package/lib/cjs/domain/JsonPropertyStore.js +14 -45
- package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
- package/lib/cjs/domain/JsonSchema.js +286 -79
- package/lib/cjs/domain/JsonSchema.js.map +1 -1
- package/lib/cjs/domain/__fixtures__/inspectOperationsPaths.js +11 -0
- package/lib/cjs/domain/__fixtures__/inspectOperationsPaths.js.map +1 -0
- package/lib/cjs/fn/email.js +2 -2
- package/lib/cjs/fn/email.js.map +1 -1
- package/lib/cjs/fn/uri.js +2 -2
- package/lib/cjs/fn/uri.js.map +1 -1
- package/lib/cjs/fn/url.js +2 -2
- package/lib/cjs/fn/url.js.map +1 -1
- package/lib/cjs/index.js +4 -8
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/generics.js +5 -36
- package/lib/cjs/utils/generics.js.map +1 -1
- package/lib/cjs/utils/getJsonEntityStore.js +3 -3
- package/lib/cjs/utils/getJsonEntityStore.js.map +1 -1
- package/lib/cjs/utils/getJsonSchema.js +24 -17
- package/lib/cjs/utils/getJsonSchema.js.map +1 -1
- package/lib/cjs/utils/getOperationsStores.js.map +1 -1
- package/lib/cjs/utils/getPropertiesStores.js.map +1 -1
- package/lib/cjs/utils/getSpec.js.map +1 -1
- package/lib/cjs/utils/mergeSchema.js +103 -0
- package/lib/cjs/utils/mergeSchema.js.map +1 -0
- package/lib/cjs/utils/ref.js +15 -13
- package/lib/cjs/utils/ref.js.map +1 -1
- package/lib/esm/components/default/anyMapper.js +1 -2
- package/lib/esm/components/default/anyMapper.js.map +1 -1
- package/lib/esm/components/default/classMapper.js +2 -22
- package/lib/esm/components/default/classMapper.js.map +1 -1
- package/lib/esm/components/default/discriminatorMappingMapper.js.map +1 -1
- package/lib/esm/components/default/genericsMapper.js +62 -48
- package/lib/esm/components/default/genericsMapper.js.map +1 -1
- package/lib/esm/components/default/inheritedClassMapper.js.map +1 -1
- package/lib/esm/components/default/lazyRefMapper.js +1 -2
- package/lib/esm/components/default/lazyRefMapper.js.map +1 -1
- package/lib/esm/components/default/mapMapper.js +0 -2
- package/lib/esm/components/default/mapMapper.js.map +1 -1
- package/lib/esm/components/default/nextMapper.js +75 -0
- package/lib/esm/components/default/nextMapper.js.map +1 -0
- package/lib/esm/components/default/nullableMapper.js.map +1 -1
- package/lib/esm/components/default/objectMapper.js +8 -3
- package/lib/esm/components/default/objectMapper.js.map +1 -1
- package/lib/esm/components/default/ofMapper.js +2 -5
- package/lib/esm/components/default/ofMapper.js.map +1 -1
- package/lib/esm/components/default/requiredMapper.js +2 -2
- package/lib/esm/components/default/requiredMapper.js.map +1 -1
- package/lib/esm/components/default/schemaMapper.js +7 -8
- package/lib/esm/components/default/schemaMapper.js.map +1 -1
- package/lib/esm/components/index.js +1 -7
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/open-spec/enumsMapper.js.map +1 -1
- package/lib/esm/components/open-spec/generate.js.map +1 -1
- package/lib/esm/components/open-spec/nullableMapper.js +5 -1
- package/lib/esm/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/esm/components/open-spec/operationInFilesMapper.js.map +1 -1
- package/lib/esm/components/open-spec/operationInParameterMapper.js +3 -7
- package/lib/esm/components/open-spec/operationInParameterMapper.js.map +1 -1
- package/lib/esm/components/open-spec/operationInQueryMapper.js +22 -17
- package/lib/esm/components/open-spec/operationInQueryMapper.js.map +1 -1
- package/lib/esm/components/open-spec/operationMediaMapper.js +5 -2
- package/lib/esm/components/open-spec/operationMediaMapper.js.map +1 -1
- package/lib/esm/components/open-spec/operationRequestBodyMapper.js +4 -3
- package/lib/esm/components/open-spec/operationRequestBodyMapper.js.map +1 -1
- package/lib/esm/components/open-spec/pathsMapper.js +1 -0
- package/lib/esm/components/open-spec/pathsMapper.js.map +1 -1
- package/lib/esm/constants/VendorKeys.js +12 -0
- package/lib/esm/constants/VendorKeys.js.map +1 -0
- package/lib/esm/constants/httpStatusMessages.js +1 -1
- package/lib/esm/constants/httpStatusMessages.js.map +1 -1
- package/lib/esm/decorators/class/children.js.map +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +29 -0
- package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
- package/lib/esm/decorators/common/allow.js.map +1 -1
- package/lib/esm/decorators/common/any.js.map +1 -1
- package/lib/esm/decorators/common/defaultMsg.js.map +1 -1
- package/lib/esm/decorators/common/description.js +9 -12
- package/lib/esm/decorators/common/description.js.map +1 -1
- package/lib/esm/decorators/common/discriminatorKey.js +1 -1
- package/lib/esm/decorators/common/discriminatorKey.js.map +1 -1
- package/lib/esm/decorators/common/enum.js.map +1 -1
- package/lib/esm/decorators/common/examples.js.map +1 -1
- package/lib/esm/decorators/common/format.js.map +1 -1
- package/lib/esm/decorators/common/forwardGroups.js +1 -1
- package/lib/esm/decorators/common/forwardGroups.js.map +1 -1
- package/lib/esm/decorators/common/groups.js +15 -26
- package/lib/esm/decorators/common/groups.js.map +1 -1
- package/lib/esm/decorators/common/integer.js.map +1 -1
- package/lib/esm/decorators/common/oneOf.js +1 -2
- package/lib/esm/decorators/common/oneOf.js.map +1 -1
- package/lib/esm/decorators/common/optional.js.map +1 -1
- package/lib/esm/decorators/config/jsonEntityComponent.js.map +1 -1
- package/lib/esm/decorators/generics/genericOf.js +8 -17
- package/lib/esm/decorators/generics/genericOf.js.map +1 -1
- package/lib/esm/decorators/generics/generics.js +3 -3
- package/lib/esm/decorators/generics/generics.js.map +1 -1
- package/lib/esm/decorators/operations/acceptMime.js.map +1 -1
- package/lib/esm/decorators/operations/consumes.js.map +1 -1
- package/lib/esm/decorators/operations/deprecated.js.map +1 -1
- package/lib/esm/decorators/operations/header.js.map +1 -1
- package/lib/esm/decorators/operations/in.js.map +1 -1
- package/lib/esm/decorators/operations/inFile.js +2 -2
- package/lib/esm/decorators/operations/inFile.js.map +1 -1
- package/lib/esm/decorators/operations/operation.js +5 -1
- package/lib/esm/decorators/operations/operation.js.map +1 -1
- package/lib/esm/decorators/operations/operationId.js.map +1 -1
- package/lib/esm/decorators/operations/operationPath.js +1 -1
- package/lib/esm/decorators/operations/operationPath.js.map +1 -1
- package/lib/esm/decorators/operations/path.js.map +1 -1
- package/lib/esm/decorators/operations/produces.js.map +1 -1
- package/lib/esm/decorators/operations/redirect.js +1 -1
- package/lib/esm/decorators/operations/redirect.js.map +1 -1
- package/lib/esm/decorators/operations/returns.js +40 -63
- package/lib/esm/decorators/operations/returns.js.map +1 -1
- package/lib/esm/decorators/operations/security.js.map +1 -1
- package/lib/esm/decorators/operations/status.js.map +1 -1
- package/lib/esm/decorators/operations/summary.js.map +1 -1
- package/lib/esm/decorators/operations/tags.js +10 -1
- package/lib/esm/decorators/operations/tags.js.map +1 -1
- package/lib/esm/domain/DecoratorContext.js.map +1 -1
- package/lib/esm/domain/JsonClassStore.js +1 -1
- package/lib/esm/domain/JsonClassStore.js.map +1 -1
- package/lib/esm/domain/JsonEntityStore.js +40 -35
- package/lib/esm/domain/JsonEntityStore.js.map +1 -1
- package/lib/esm/domain/JsonLazyRef.js.map +1 -1
- package/lib/esm/domain/JsonMap.js.map +1 -1
- package/lib/esm/domain/JsonMedia.js +27 -6
- package/lib/esm/domain/JsonMedia.js.map +1 -1
- package/lib/esm/domain/JsonMethodStore.js +28 -9
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/domain/JsonOperation.js +34 -7
- package/lib/esm/domain/JsonOperation.js.map +1 -1
- package/lib/esm/domain/JsonParameter.js +20 -5
- package/lib/esm/domain/JsonParameter.js.map +1 -1
- package/lib/esm/domain/JsonParameterStore.js +16 -26
- package/lib/esm/domain/JsonParameterStore.js.map +1 -1
- package/lib/esm/domain/JsonPropertyStore.js +15 -46
- package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
- package/lib/esm/domain/JsonSchema.js +287 -80
- package/lib/esm/domain/JsonSchema.js.map +1 -1
- package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js +7 -0
- package/lib/esm/domain/__fixtures__/inspectOperationsPaths.js.map +1 -0
- package/lib/esm/fn/email.js +2 -2
- package/lib/esm/fn/email.js.map +1 -1
- package/lib/esm/fn/uri.js +2 -2
- package/lib/esm/fn/uri.js.map +1 -1
- package/lib/esm/fn/url.js +2 -2
- package/lib/esm/fn/url.js.map +1 -1
- package/lib/esm/index.js +4 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/generics.js +3 -32
- package/lib/esm/utils/generics.js.map +1 -1
- package/lib/esm/utils/getJsonEntityStore.js +3 -3
- package/lib/esm/utils/getJsonEntityStore.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +24 -17
- package/lib/esm/utils/getJsonSchema.js.map +1 -1
- package/lib/esm/utils/getOperationsStores.js.map +1 -1
- package/lib/esm/utils/getPropertiesStores.js.map +1 -1
- package/lib/esm/utils/getSpec.js.map +1 -1
- package/lib/esm/utils/mergeSchema.js +99 -0
- package/lib/esm/utils/mergeSchema.js.map +1 -0
- package/lib/esm/utils/ref.js +14 -13
- package/lib/esm/utils/ref.js.map +1 -1
- package/lib/types/components/default/classMapper.d.ts +1 -1
- package/lib/types/components/default/genericsMapper.d.ts +9 -2
- package/lib/types/components/default/lazyRefMapper.d.ts +1 -1
- package/lib/types/components/default/nextMapper.d.ts +5 -0
- package/lib/types/components/default/ofMapper.d.ts +1 -1
- package/lib/types/components/index.d.ts +1 -7
- package/lib/types/components/open-spec/nullableMapper.d.ts +2 -1
- package/lib/types/components/open-spec/operationInQueryMapper.d.ts +1 -1
- package/lib/types/constants/VendorKeys.d.ts +10 -0
- package/lib/types/decorators/collections/collectionOf.d.ts +6 -0
- package/lib/types/decorators/generics/genericOf.d.ts +3 -0
- package/lib/types/decorators/generics/generics.d.ts +2 -2
- package/lib/types/decorators/operations/acceptMime.d.ts +1 -1
- package/lib/types/decorators/operations/consumes.d.ts +1 -1
- package/lib/types/decorators/operations/header.d.ts +1 -1
- package/lib/types/decorators/operations/operationId.d.ts +1 -1
- package/lib/types/decorators/operations/operationPath.d.ts +1 -1
- package/lib/types/decorators/operations/path.d.ts +1 -1
- package/lib/types/decorators/operations/returns.d.ts +11 -9
- package/lib/types/decorators/operations/tags.d.ts +11 -2
- package/lib/types/domain/JsonClassStore.d.ts +1 -1
- package/lib/types/domain/JsonEntityStore.d.ts +20 -16
- package/lib/types/domain/JsonMedia.d.ts +4 -5
- package/lib/types/domain/JsonMethodStore.d.ts +9 -2
- package/lib/types/domain/JsonOperation.d.ts +7 -4
- package/lib/types/domain/JsonParameter.d.ts +4 -7
- package/lib/types/domain/JsonParameterStore.d.ts +1 -4
- package/lib/types/domain/JsonPropertyStore.d.ts +2 -21
- package/lib/types/domain/JsonSchema.d.ts +83 -40
- package/lib/types/domain/__fixtures__/inspectOperationsPaths.d.ts +5 -0
- package/lib/types/index.d.ts +4 -8
- package/lib/types/interfaces/JsonSchemaOptions.d.ts +16 -2
- package/lib/types/utils/generics.d.ts +7 -48
- package/lib/types/utils/getJsonEntityStore.d.ts +3 -3
- package/lib/types/utils/getJsonSchema.d.ts +3 -2
- package/lib/types/utils/mergeSchema.d.ts +2 -0
- package/lib/types/utils/ref.d.ts +4 -2
- package/lib/types-esm/components/default/classMapper.d.ts +1 -1
- package/lib/types-esm/components/default/genericsMapper.d.ts +9 -2
- package/lib/types-esm/components/default/lazyRefMapper.d.ts +1 -1
- package/lib/types-esm/components/default/nextMapper.d.ts +5 -0
- package/lib/types-esm/components/default/ofMapper.d.ts +1 -1
- package/lib/types-esm/components/index.d.ts +1 -7
- package/lib/types-esm/components/open-spec/nullableMapper.d.ts +2 -1
- package/lib/types-esm/components/open-spec/operationInQueryMapper.d.ts +1 -1
- package/lib/types-esm/constants/VendorKeys.d.ts +10 -0
- package/lib/types-esm/decorators/collections/collectionOf.d.ts +6 -0
- package/lib/types-esm/decorators/generics/genericOf.d.ts +3 -0
- package/lib/types-esm/decorators/generics/generics.d.ts +2 -2
- package/lib/types-esm/decorators/operations/acceptMime.d.ts +1 -1
- package/lib/types-esm/decorators/operations/consumes.d.ts +1 -1
- package/lib/types-esm/decorators/operations/header.d.ts +1 -1
- package/lib/types-esm/decorators/operations/operationId.d.ts +1 -1
- package/lib/types-esm/decorators/operations/operationPath.d.ts +1 -1
- package/lib/types-esm/decorators/operations/path.d.ts +1 -1
- package/lib/types-esm/decorators/operations/returns.d.ts +11 -9
- package/lib/types-esm/decorators/operations/tags.d.ts +11 -2
- package/lib/types-esm/domain/JsonClassStore.d.ts +1 -1
- package/lib/types-esm/domain/JsonEntityStore.d.ts +20 -16
- package/lib/types-esm/domain/JsonMedia.d.ts +4 -5
- package/lib/types-esm/domain/JsonMethodStore.d.ts +9 -2
- package/lib/types-esm/domain/JsonOperation.d.ts +7 -4
- package/lib/types-esm/domain/JsonParameter.d.ts +4 -7
- package/lib/types-esm/domain/JsonParameterStore.d.ts +1 -4
- package/lib/types-esm/domain/JsonPropertyStore.d.ts +2 -21
- package/lib/types-esm/domain/JsonSchema.d.ts +83 -40
- package/lib/types-esm/domain/__fixtures__/inspectOperationsPaths.d.ts +5 -0
- package/lib/types-esm/index.d.ts +4 -8
- package/lib/types-esm/interfaces/JsonSchemaOptions.d.ts +16 -2
- package/lib/types-esm/utils/generics.d.ts +7 -48
- package/lib/types-esm/utils/getJsonEntityStore.d.ts +3 -3
- package/lib/types-esm/utils/getJsonSchema.d.ts +3 -2
- package/lib/types-esm/utils/mergeSchema.d.ts +2 -0
- package/lib/types-esm/utils/ref.d.ts +4 -2
- package/package.json +6 -6
- package/lib/cjs/components/async-api/channelsMapper.js +0 -62
- package/lib/cjs/components/async-api/channelsMapper.js.map +0 -1
- package/lib/cjs/components/async-api/generate.js +0 -20
- package/lib/cjs/components/async-api/generate.js.map +0 -1
- package/lib/cjs/components/async-api/messageMapper.js +0 -44
- package/lib/cjs/components/async-api/messageMapper.js.map +0 -1
- package/lib/cjs/components/async-api/payloadMapper.js +0 -52
- package/lib/cjs/components/async-api/payloadMapper.js.map +0 -1
- package/lib/cjs/components/async-api/responseMapper.js +0 -58
- package/lib/cjs/components/async-api/responseMapper.js.map +0 -1
- package/lib/cjs/components/default/itemMapper.js +0 -10
- package/lib/cjs/components/default/itemMapper.js.map +0 -1
- package/lib/cjs/components/default/propertiesMapper.js +0 -25
- package/lib/cjs/components/default/propertiesMapper.js.map +0 -1
- package/lib/cjs/utils/somethingOf.js +0 -16
- package/lib/cjs/utils/somethingOf.js.map +0 -1
- package/lib/esm/components/async-api/channelsMapper.js +0 -58
- package/lib/esm/components/async-api/channelsMapper.js.map +0 -1
- package/lib/esm/components/async-api/generate.js +0 -18
- package/lib/esm/components/async-api/generate.js.map +0 -1
- package/lib/esm/components/async-api/messageMapper.js +0 -40
- package/lib/esm/components/async-api/messageMapper.js.map +0 -1
- package/lib/esm/components/async-api/payloadMapper.js +0 -48
- package/lib/esm/components/async-api/payloadMapper.js.map +0 -1
- package/lib/esm/components/async-api/responseMapper.js +0 -54
- package/lib/esm/components/async-api/responseMapper.js.map +0 -1
- package/lib/esm/components/default/itemMapper.js +0 -6
- package/lib/esm/components/default/itemMapper.js.map +0 -1
- package/lib/esm/components/default/propertiesMapper.js +0 -21
- package/lib/esm/components/default/propertiesMapper.js.map +0 -1
- package/lib/esm/utils/somethingOf.js +0 -12
- package/lib/esm/utils/somethingOf.js.map +0 -1
- package/lib/types/components/async-api/channelsMapper.d.ts +0 -2
- package/lib/types/components/async-api/generate.d.ts +0 -1
- package/lib/types/components/async-api/messageMapper.d.ts +0 -6
- package/lib/types/components/async-api/payloadMapper.d.ts +0 -4
- package/lib/types/components/async-api/responseMapper.d.ts +0 -6
- package/lib/types/components/default/itemMapper.d.ts +0 -2
- package/lib/types/components/default/propertiesMapper.d.ts +0 -3
- package/lib/types/utils/somethingOf.d.ts +0 -1
- package/lib/types-esm/components/async-api/channelsMapper.d.ts +0 -2
- package/lib/types-esm/components/async-api/generate.d.ts +0 -1
- package/lib/types-esm/components/async-api/messageMapper.d.ts +0 -6
- package/lib/types-esm/components/async-api/payloadMapper.d.ts +0 -4
- package/lib/types-esm/components/async-api/responseMapper.d.ts +0 -6
- package/lib/types-esm/components/default/itemMapper.d.ts +0 -2
- package/lib/types-esm/components/default/propertiesMapper.d.ts +0 -3
- package/lib/types-esm/utils/somethingOf.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,qCAAgF;AAEhF,wFAAgF;AAEhF,6DAAqD;AACrD,mDAA2C;AAGpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,oCAAe;IAA/C;;QACI,WAAM,GAAmB,oCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAqCtE,CAAC;IAnCC,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B;QACxD,OAAO,oCAAe,CAAC,IAAI,CAAoB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;IAES,KAAK;QACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,eAAQ,CAAC,OAAO,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAElC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAExD,IAAI,MAAM,GAAe,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEvD,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAElD,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,MAAM,GAAG,0BAAU,CAAC,IAAI,CAAC;oBACvB,IAAI,EAAE,IAAI,CAAC,cAAc;iBAC1B,CAAC,CAAC;gBACH,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;iBAAM,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC7B,MAAM,GAAG,0BAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC;gBAC3C,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;iBAAM;gBACL,MAAM,GAAG,0BAAU,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAC,CAAC,CAAC;aAC7C;SACF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;CACF,CAAA;AAtCY,iBAAiB;IAD7B,IAAA,4CAAmB,EAAC,qBAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,CAsC7B;AAtCY,8CAAiB;AA4CjB,QAAA,gBAAgB,GAAG,iBAAiB,CAAC"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonSchema = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
|
+
const VendorKeys_js_1 = require("../constants/VendorKeys.js");
|
|
5
6
|
const enumRegistries_js_1 = require("../registries/enumRegistries.js");
|
|
6
7
|
const JsonSchemaMapperContainer_js_1 = require("../registries/JsonSchemaMapperContainer.js");
|
|
7
8
|
const getComputedType_js_1 = require("../utils/getComputedType.js");
|
|
8
9
|
const getJsonType_js_1 = require("../utils/getJsonType.js");
|
|
10
|
+
const matchGroups_js_1 = require("../utils/matchGroups.js");
|
|
9
11
|
const serializeEnumValues_js_1 = require("../utils/serializeEnumValues.js");
|
|
10
12
|
const toJsonRegex_js_1 = require("../utils/toJsonRegex.js");
|
|
11
13
|
const JsonDiscriminator_js_1 = require("./JsonDiscriminator.js");
|
|
@@ -17,6 +19,9 @@ function mapProperties(properties) {
|
|
|
17
19
|
}
|
|
18
20
|
return Object.entries(properties).reduce((properties, [key, schema]) => {
|
|
19
21
|
properties[(0, toJsonRegex_js_1.toJsonRegex)(key)] = mapToJsonSchema(schema);
|
|
22
|
+
if (schema instanceof JsonSchema) {
|
|
23
|
+
schema.propertyKey((0, toJsonRegex_js_1.toJsonRegex)(key));
|
|
24
|
+
}
|
|
20
25
|
return properties;
|
|
21
26
|
}, {});
|
|
22
27
|
}
|
|
@@ -38,35 +43,83 @@ function mapToJsonSchema(item) {
|
|
|
38
43
|
}
|
|
39
44
|
return item;
|
|
40
45
|
}
|
|
46
|
+
function isEnum(type) {
|
|
47
|
+
return (0, core_1.isObject)(type) && !("toJSON" in type);
|
|
48
|
+
}
|
|
49
|
+
function mapGenerics(jsonSchema, generics) {
|
|
50
|
+
const genericLabels = jsonSchema.getGenericLabels();
|
|
51
|
+
if (!genericLabels) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
const [types, ...nextTypes] = generics;
|
|
55
|
+
return types.reduce((mapping, type, index) => {
|
|
56
|
+
const label = genericLabels[index];
|
|
57
|
+
if (label) {
|
|
58
|
+
if (isEnum(type)) {
|
|
59
|
+
mapping[label] = [JsonSchema.from({ type: "string", enum: Object.values(type) })];
|
|
60
|
+
}
|
|
61
|
+
else if (nextTypes.length) {
|
|
62
|
+
const nextSchema = mapToJsonSchema(type);
|
|
63
|
+
mapping[label] = [nextSchema, mapGenerics(nextSchema, nextTypes)];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
mapping[label] = [mapToJsonSchema(type)];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return mapping;
|
|
70
|
+
}, {});
|
|
71
|
+
}
|
|
41
72
|
class JsonSchema extends Map {
|
|
42
|
-
|
|
73
|
+
/**
|
|
74
|
+
* All required fields are stored here
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
#required;
|
|
78
|
+
/**
|
|
79
|
+
* Internal custom props
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
#vendors;
|
|
43
83
|
#discriminator;
|
|
44
|
-
#genericLabels;
|
|
45
|
-
#nestedGenerics;
|
|
46
84
|
#alias;
|
|
47
85
|
#itemSchema;
|
|
86
|
+
/**
|
|
87
|
+
* This flag is used to know if the schema is created to link property/param to a class schema.
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
#isLocalSchema;
|
|
48
91
|
#target;
|
|
49
|
-
#isGeneric;
|
|
50
92
|
#isCollection;
|
|
51
|
-
#
|
|
93
|
+
#useRefLabel;
|
|
94
|
+
#propertyKey;
|
|
52
95
|
constructor(obj = {}) {
|
|
53
96
|
super();
|
|
54
97
|
this.$kind = "schema";
|
|
55
98
|
this.$isJsonDocument = true;
|
|
56
99
|
this.$hooks = new core_1.Hooks();
|
|
57
|
-
this.$required = new Set();
|
|
58
100
|
this.$allow = [];
|
|
59
|
-
this.$forwardGroups = false;
|
|
60
101
|
this.$ignore = false;
|
|
61
102
|
this.isDiscriminatorKey = false;
|
|
62
103
|
this.isDiscriminator = false;
|
|
63
|
-
|
|
104
|
+
/**
|
|
105
|
+
* All required fields are stored here
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
this.#required = new Set();
|
|
109
|
+
/**
|
|
110
|
+
* Internal custom props
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
this.#vendors = new Map();
|
|
64
114
|
this.#discriminator = null;
|
|
65
|
-
this.#nestedGenerics = [];
|
|
66
115
|
this.#alias = new Map();
|
|
67
|
-
|
|
116
|
+
/**
|
|
117
|
+
* This flag is used to know if the schema is created to link property/param to a class schema.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
this.#isLocalSchema = false;
|
|
68
121
|
this.#isCollection = false;
|
|
69
|
-
this.#
|
|
122
|
+
this.#useRefLabel = false;
|
|
70
123
|
if (obj) {
|
|
71
124
|
this.assign(obj);
|
|
72
125
|
}
|
|
@@ -74,32 +127,27 @@ class JsonSchema extends Map {
|
|
|
74
127
|
get alias() {
|
|
75
128
|
return this.#alias;
|
|
76
129
|
}
|
|
77
|
-
get nestedGenerics() {
|
|
78
|
-
return this.#nestedGenerics;
|
|
79
|
-
}
|
|
80
|
-
set nestedGenerics(value) {
|
|
81
|
-
this.#nestedGenerics = value;
|
|
82
|
-
}
|
|
83
|
-
get genericLabels() {
|
|
84
|
-
return this.#genericLabels;
|
|
85
|
-
}
|
|
86
|
-
set genericLabels(value) {
|
|
87
|
-
this.#genericLabels = value;
|
|
88
|
-
}
|
|
89
130
|
get isClass() {
|
|
90
|
-
return (0, core_1.isClass)(this.class) && !
|
|
131
|
+
return (0, core_1.isClass)(this.class) && !this.isCollection;
|
|
91
132
|
}
|
|
92
133
|
/**
|
|
93
|
-
*
|
|
134
|
+
* The current schema is a collection
|
|
94
135
|
*/
|
|
95
136
|
get isCollection() {
|
|
96
137
|
return this.#isCollection;
|
|
97
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* The current schema is a reference to another schema
|
|
141
|
+
* to link property/param to a class schema (if the reference exists).
|
|
142
|
+
*/
|
|
143
|
+
get isLocalSchema() {
|
|
144
|
+
return this.#isLocalSchema;
|
|
145
|
+
}
|
|
98
146
|
/**
|
|
99
147
|
* Current schema is a generic
|
|
100
148
|
*/
|
|
101
149
|
get isGeneric() {
|
|
102
|
-
return this
|
|
150
|
+
return this.has(VendorKeys_js_1.VendorKeys.GENERIC_LABEL);
|
|
103
151
|
}
|
|
104
152
|
get discriminatorAncestor() {
|
|
105
153
|
const ancestors = (0, core_1.ancestorsOf)(this.#target);
|
|
@@ -107,22 +155,27 @@ class JsonSchema extends Map {
|
|
|
107
155
|
return ancestor && JsonEntityStore_js_1.JsonEntityStore.from(ancestor).schema;
|
|
108
156
|
}
|
|
109
157
|
/**
|
|
110
|
-
*
|
|
158
|
+
* Return the itemSchema computed type.
|
|
159
|
+
* If the type is a function used for a recursive model,
|
|
160
|
+
* the function will be called to get the right type.
|
|
111
161
|
*/
|
|
112
|
-
get hasGenerics() {
|
|
113
|
-
return !!(this.nestedGenerics && this.nestedGenerics.length);
|
|
114
|
-
}
|
|
115
|
-
get genericType() {
|
|
116
|
-
return this.get("$ref");
|
|
117
|
-
}
|
|
118
162
|
get class() {
|
|
119
|
-
|
|
163
|
+
if (this.#isLocalSchema) {
|
|
164
|
+
return this.#itemSchema?.getTarget();
|
|
165
|
+
}
|
|
166
|
+
return (0, getComputedType_js_1.getComputedType)(this.#target);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Return the itemSchema computed type.
|
|
170
|
+
*/
|
|
171
|
+
get collectionClass() {
|
|
172
|
+
return this.isCollection && this.#itemSchema ? this.#itemSchema.class : this.class;
|
|
120
173
|
}
|
|
121
174
|
get canRef() {
|
|
122
|
-
return this.#
|
|
175
|
+
return this.#useRefLabel;
|
|
123
176
|
}
|
|
124
177
|
get isNullable() {
|
|
125
|
-
return this
|
|
178
|
+
return !!this.get("nullable");
|
|
126
179
|
}
|
|
127
180
|
get isReadOnly() {
|
|
128
181
|
return this.get("readOnly");
|
|
@@ -133,15 +186,105 @@ class JsonSchema extends Map {
|
|
|
133
186
|
get hasDiscriminator() {
|
|
134
187
|
return !!this.#discriminator;
|
|
135
188
|
}
|
|
136
|
-
static from(
|
|
137
|
-
|
|
189
|
+
static from(item = {}) {
|
|
190
|
+
if (item instanceof JsonSchema) {
|
|
191
|
+
return item;
|
|
192
|
+
}
|
|
193
|
+
if ((0, core_1.classOf)(item) !== Object && (0, core_1.isClass)(item)) {
|
|
194
|
+
return JsonEntityStore_js_1.JsonEntityStore.from(item).schema;
|
|
195
|
+
}
|
|
196
|
+
if ((0, core_1.isPrimitiveClass)(item)) {
|
|
197
|
+
return new JsonSchema({ type: item });
|
|
198
|
+
}
|
|
199
|
+
return new JsonSchema(item);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Check if the schema as key, #key or x-key
|
|
203
|
+
* @param key
|
|
204
|
+
*/
|
|
205
|
+
has(key) {
|
|
206
|
+
if (super.has(key)) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
if (super.has(`#${key}`)) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
return this.#vendors.has(key);
|
|
213
|
+
}
|
|
214
|
+
get(key, defaultValue) {
|
|
215
|
+
if (this.#vendors.has(key)) {
|
|
216
|
+
return this.#vendors.get(key);
|
|
217
|
+
}
|
|
218
|
+
if (super.has(key)) {
|
|
219
|
+
return super.get(key);
|
|
220
|
+
}
|
|
221
|
+
if (super.has(`#${key}`)) {
|
|
222
|
+
return super.get(`#${key}`);
|
|
223
|
+
}
|
|
224
|
+
return defaultValue;
|
|
225
|
+
}
|
|
226
|
+
forwardGroups(bool = true) {
|
|
227
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.FORWARD_GROUPS, bool);
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
groups(groups, isProperty) {
|
|
231
|
+
if (groups) {
|
|
232
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.GROUPS, groups);
|
|
233
|
+
// this.customKey("x-groups", groups);
|
|
234
|
+
if (isProperty) {
|
|
235
|
+
this.$hooks.on("groups", (prev, givenGroups) => {
|
|
236
|
+
if (!prev) {
|
|
237
|
+
if ((0, matchGroups_js_1.matchGroups)(groups, givenGroups)) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return prev;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
groupsName(groupsName) {
|
|
248
|
+
groupsName && this.vendorKey(VendorKeys_js_1.VendorKeys.GROUPS_NAME, groupsName);
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
allowedGroups(groups) {
|
|
252
|
+
groups && this.vendorKey(VendorKeys_js_1.VendorKeys.ALLOWED_GROUPS, groups);
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Assign the Generic Labels used over a class or a schema.
|
|
257
|
+
* @param genericLabels
|
|
258
|
+
*/
|
|
259
|
+
genericLabels(genericLabels) {
|
|
260
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.GENERIC_LABELS, genericLabels);
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
genericLabel(genericLabel) {
|
|
264
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.GENERIC_LABEL, genericLabel);
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Assign the types of the generics that must be used for the property
|
|
269
|
+
* @param generics
|
|
270
|
+
*/
|
|
271
|
+
genericOf(...generics) {
|
|
272
|
+
const mapped = mapGenerics(this.#itemSchema || mapToJsonSchema(this.getTarget()), generics);
|
|
273
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.GENERIC_OF, mapped);
|
|
274
|
+
return this;
|
|
138
275
|
}
|
|
139
276
|
nullable(value) {
|
|
140
|
-
this
|
|
277
|
+
this.vendorKey(VendorKeys_js_1.VendorKeys.NULLABLE, value);
|
|
278
|
+
return this;
|
|
141
279
|
}
|
|
142
280
|
itemSchema(obj = {}) {
|
|
143
281
|
this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);
|
|
144
|
-
|
|
282
|
+
if ((0, core_1.isPlainObject)(obj)) {
|
|
283
|
+
this.#itemSchema.assign(obj);
|
|
284
|
+
}
|
|
285
|
+
if (!this.isCollection && this.#itemSchema?.isClass) {
|
|
286
|
+
this.#isLocalSchema = true;
|
|
287
|
+
}
|
|
145
288
|
return this.#itemSchema;
|
|
146
289
|
}
|
|
147
290
|
getAliasOf(property) {
|
|
@@ -175,7 +318,7 @@ class JsonSchema extends Map {
|
|
|
175
318
|
* @param name
|
|
176
319
|
*/
|
|
177
320
|
label(name) {
|
|
178
|
-
this.#
|
|
321
|
+
this.#useRefLabel = true;
|
|
179
322
|
super.set("name", name);
|
|
180
323
|
return this;
|
|
181
324
|
}
|
|
@@ -227,6 +370,15 @@ class JsonSchema extends Map {
|
|
|
227
370
|
discriminatorKey(propertyName) {
|
|
228
371
|
this.discriminator().propertyName = propertyName;
|
|
229
372
|
this.isDiscriminator = true;
|
|
373
|
+
const propertySchema = this.get("properties")[propertyName];
|
|
374
|
+
if (propertySchema) {
|
|
375
|
+
if (propertySchema.isCollection) {
|
|
376
|
+
propertySchema.itemSchema().isDiscriminatorKey = true;
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
propertySchema.isDiscriminatorKey = true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
230
382
|
return this;
|
|
231
383
|
}
|
|
232
384
|
discriminatorValue(...values) {
|
|
@@ -370,8 +522,8 @@ class JsonSchema extends Map {
|
|
|
370
522
|
*/
|
|
371
523
|
required(required = true) {
|
|
372
524
|
if ((0, core_1.isArray)(required)) {
|
|
373
|
-
this
|
|
374
|
-
required.forEach((value) => this
|
|
525
|
+
this.#required.clear();
|
|
526
|
+
required.forEach((value) => this.#required.add(value));
|
|
375
527
|
}
|
|
376
528
|
else {
|
|
377
529
|
const schema = this.clone();
|
|
@@ -384,15 +536,18 @@ class JsonSchema extends Map {
|
|
|
384
536
|
return this;
|
|
385
537
|
}
|
|
386
538
|
addRequired(property) {
|
|
387
|
-
this
|
|
539
|
+
this.#required.add(property);
|
|
388
540
|
return this;
|
|
389
541
|
}
|
|
390
542
|
removeRequired(property) {
|
|
391
|
-
this
|
|
543
|
+
this.#required.delete(property);
|
|
392
544
|
return this;
|
|
393
545
|
}
|
|
394
546
|
isRequired(property) {
|
|
395
|
-
return this
|
|
547
|
+
return this.#required.has(property);
|
|
548
|
+
}
|
|
549
|
+
getRequiredFields() {
|
|
550
|
+
return [...this.#required];
|
|
396
551
|
}
|
|
397
552
|
/**
|
|
398
553
|
* This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.
|
|
@@ -510,7 +665,12 @@ class JsonSchema extends Map {
|
|
|
510
665
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
|
511
666
|
*/
|
|
512
667
|
oneOf(oneOf) {
|
|
513
|
-
this.
|
|
668
|
+
if (this.isCollection) {
|
|
669
|
+
this.itemSchema().oneOf(oneOf);
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
this.setManyOf("oneOf", oneOf);
|
|
673
|
+
}
|
|
514
674
|
return this;
|
|
515
675
|
}
|
|
516
676
|
/**
|
|
@@ -608,7 +768,7 @@ class JsonSchema extends Map {
|
|
|
608
768
|
case "map":
|
|
609
769
|
case Map:
|
|
610
770
|
super.set("type", (0, getJsonType_js_1.getJsonType)(type));
|
|
611
|
-
this
|
|
771
|
+
this.target(type);
|
|
612
772
|
this.#isCollection = true;
|
|
613
773
|
if (!this.has("additionalProperties")) {
|
|
614
774
|
super.set("additionalProperties", this.itemSchema({}));
|
|
@@ -617,7 +777,7 @@ class JsonSchema extends Map {
|
|
|
617
777
|
case "array":
|
|
618
778
|
case Array:
|
|
619
779
|
super.set("type", (0, getJsonType_js_1.getJsonType)(type));
|
|
620
|
-
this
|
|
780
|
+
this.target(type);
|
|
621
781
|
this.#isCollection = true;
|
|
622
782
|
if (!this.has("items")) {
|
|
623
783
|
super.set("items", this.itemSchema({}));
|
|
@@ -626,7 +786,7 @@ class JsonSchema extends Map {
|
|
|
626
786
|
case "set":
|
|
627
787
|
case Set:
|
|
628
788
|
super.set("type", (0, getJsonType_js_1.getJsonType)(type));
|
|
629
|
-
this
|
|
789
|
+
this.target(type);
|
|
630
790
|
this.#isCollection = true;
|
|
631
791
|
this.uniqueItems(true);
|
|
632
792
|
if (!this.has("items")) {
|
|
@@ -646,7 +806,7 @@ class JsonSchema extends Map {
|
|
|
646
806
|
case Number:
|
|
647
807
|
case String:
|
|
648
808
|
super.set("type", (0, getJsonType_js_1.getJsonType)(type));
|
|
649
|
-
this
|
|
809
|
+
this.target(type);
|
|
650
810
|
if (!this.has("properties")) {
|
|
651
811
|
super.set("properties", {});
|
|
652
812
|
}
|
|
@@ -654,7 +814,7 @@ class JsonSchema extends Map {
|
|
|
654
814
|
default:
|
|
655
815
|
if ((0, core_1.isClass)(type) || (0, core_1.isFunction)(type)) {
|
|
656
816
|
super.set("type", undefined);
|
|
657
|
-
this
|
|
817
|
+
this.target(type);
|
|
658
818
|
if (!this.has("properties")) {
|
|
659
819
|
super.set("properties", {});
|
|
660
820
|
}
|
|
@@ -662,8 +822,7 @@ class JsonSchema extends Map {
|
|
|
662
822
|
else {
|
|
663
823
|
const jsonType = (0, getJsonType_js_1.getJsonType)(type);
|
|
664
824
|
if (jsonType === "generic") {
|
|
665
|
-
this
|
|
666
|
-
super.set("$ref", type);
|
|
825
|
+
this.genericLabel(type);
|
|
667
826
|
}
|
|
668
827
|
else {
|
|
669
828
|
super.set("type", jsonType);
|
|
@@ -711,6 +870,10 @@ class JsonSchema extends Map {
|
|
|
711
870
|
super.set(`#${key}`, value);
|
|
712
871
|
return this;
|
|
713
872
|
}
|
|
873
|
+
vendorKey(key, value) {
|
|
874
|
+
this.#vendors.set(key, value);
|
|
875
|
+
return this;
|
|
876
|
+
}
|
|
714
877
|
toObject(options) {
|
|
715
878
|
return this.toJSON(options);
|
|
716
879
|
}
|
|
@@ -725,21 +888,16 @@ class JsonSchema extends Map {
|
|
|
725
888
|
if (obj instanceof JsonSchema) {
|
|
726
889
|
this.$selfRequired = obj.$selfRequired;
|
|
727
890
|
this.$allow.push(...obj.$allow);
|
|
728
|
-
obj
|
|
729
|
-
|
|
730
|
-
|
|
891
|
+
this.#required = new Set(obj.#required.keys());
|
|
892
|
+
this.#alias = new Map(this.#alias.entries());
|
|
893
|
+
this.#vendors = new Map(obj.#vendors.entries());
|
|
731
894
|
this.#discriminator = this.#discriminator ? new JsonDiscriminator_js_1.Discriminator(this.#discriminator) : null;
|
|
732
895
|
this.isDiscriminator = obj.isDiscriminator;
|
|
733
896
|
this.isDiscriminatorKey = obj.isDiscriminatorKey;
|
|
734
|
-
this.#
|
|
735
|
-
this.#alias = new Map(this.#alias.entries());
|
|
736
|
-
obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);
|
|
737
|
-
this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);
|
|
897
|
+
this.#useRefLabel = obj.#useRefLabel;
|
|
738
898
|
this.#target = obj.#target;
|
|
739
|
-
this.#isGeneric = obj.#isGeneric;
|
|
740
899
|
this.#isCollection = obj.#isCollection;
|
|
741
|
-
this.#
|
|
742
|
-
this.#nullable = obj.#nullable;
|
|
900
|
+
this.#isLocalSchema = obj.#isLocalSchema;
|
|
743
901
|
super.set("type", obj.get("type"));
|
|
744
902
|
}
|
|
745
903
|
return this;
|
|
@@ -753,17 +911,6 @@ class JsonSchema extends Map {
|
|
|
753
911
|
}
|
|
754
912
|
return this;
|
|
755
913
|
}
|
|
756
|
-
/**
|
|
757
|
-
* Return the itemSchema computed type.
|
|
758
|
-
* If the type is a function used for recursive model,
|
|
759
|
-
* the function will be called to get the right type.
|
|
760
|
-
*/
|
|
761
|
-
getComputedType() {
|
|
762
|
-
return (0, getComputedType_js_1.getComputedType)(this.#target);
|
|
763
|
-
}
|
|
764
|
-
getComputedItemType() {
|
|
765
|
-
return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();
|
|
766
|
-
}
|
|
767
914
|
/**
|
|
768
915
|
* Return the Json type as string
|
|
769
916
|
*/
|
|
@@ -773,24 +920,84 @@ class JsonSchema extends Map {
|
|
|
773
920
|
return o.getJsonType();
|
|
774
921
|
});
|
|
775
922
|
}
|
|
776
|
-
return this.get("type") || (0, getJsonType_js_1.getJsonType)(this.
|
|
923
|
+
return this.get("type") || (0, getJsonType_js_1.getJsonType)(this.class);
|
|
777
924
|
}
|
|
778
925
|
getTarget() {
|
|
779
926
|
return this.#target;
|
|
780
927
|
}
|
|
928
|
+
getAllowedGroups() {
|
|
929
|
+
return this.get(VendorKeys_js_1.VendorKeys.ALLOWED_GROUPS);
|
|
930
|
+
}
|
|
931
|
+
getAllowedRequiredValues() {
|
|
932
|
+
return this.$allow;
|
|
933
|
+
}
|
|
934
|
+
getGroups() {
|
|
935
|
+
return this.get(VendorKeys_js_1.VendorKeys.GROUPS);
|
|
936
|
+
}
|
|
937
|
+
getGroupsName() {
|
|
938
|
+
return this.get(VendorKeys_js_1.VendorKeys.GROUPS_NAME);
|
|
939
|
+
}
|
|
781
940
|
/**
|
|
782
941
|
* Get the symbolic name of the entity
|
|
783
942
|
*/
|
|
784
943
|
getName() {
|
|
785
|
-
return this.get("name") || ((0, core_1.isClass)(this.#target) ? (0, core_1.nameOf)((0, core_1.classOf)(this.
|
|
944
|
+
return this.get("name") || ((0, core_1.isClass)(this.#target) ? (0, core_1.nameOf)((0, core_1.classOf)(this.class)) : "");
|
|
786
945
|
}
|
|
787
946
|
clone() {
|
|
788
947
|
return new JsonSchema(this);
|
|
789
948
|
}
|
|
949
|
+
getGenericLabels() {
|
|
950
|
+
const labels = this.get(VendorKeys_js_1.VendorKeys.GENERIC_LABELS);
|
|
951
|
+
if (this.isClass && !labels) {
|
|
952
|
+
const ancestor = (0, core_1.ancestorOf)(this.class);
|
|
953
|
+
return ancestor === Object ? undefined : JsonSchema.from(ancestor).getGenericLabels();
|
|
954
|
+
}
|
|
955
|
+
return this.get(VendorKeys_js_1.VendorKeys.GENERIC_LABELS);
|
|
956
|
+
}
|
|
957
|
+
getGenericOf() {
|
|
958
|
+
return this.get(VendorKeys_js_1.VendorKeys.GENERIC_OF);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Returns the reference schema for class-based schemas.
|
|
962
|
+
* Used to get the original schema definition when this schema is a local reference.
|
|
963
|
+
* @returns The reference schema or undefined if not applicable
|
|
964
|
+
*/
|
|
965
|
+
getRefSchema() {
|
|
966
|
+
if (!this.isLocalSchema && this.isClass) {
|
|
967
|
+
const refSchema = JsonSchema.from(this.class);
|
|
968
|
+
if (refSchema !== this) {
|
|
969
|
+
return refSchema;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
propertyKey(s) {
|
|
974
|
+
this.#propertyKey = s;
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
getPropertyKey() {
|
|
978
|
+
return this.#propertyKey;
|
|
979
|
+
}
|
|
980
|
+
target(target) {
|
|
981
|
+
if (target === "object") {
|
|
982
|
+
this.#target = Object;
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
this.#target = target;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
isRequiredValue(property, value) {
|
|
989
|
+
if (this.isRequired(property) && [undefined, null, ""].includes(value)) {
|
|
990
|
+
const propertySchema = this.get("properties")?.[property];
|
|
991
|
+
if (propertySchema) {
|
|
992
|
+
return !propertySchema.getAllowedRequiredValues().includes(value);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
790
997
|
setManyOf(keyword, value) {
|
|
791
998
|
let resolved = value
|
|
792
999
|
.filter((o) => {
|
|
793
|
-
if (o
|
|
1000
|
+
if (o && "type" in o && o.type === "null") {
|
|
794
1001
|
this.nullable(true);
|
|
795
1002
|
return false;
|
|
796
1003
|
}
|
|
@@ -809,7 +1016,7 @@ class JsonSchema extends Map {
|
|
|
809
1016
|
}
|
|
810
1017
|
super.set(keyword, resolved);
|
|
811
1018
|
const jsonSchema = resolved[0];
|
|
812
|
-
if (jsonSchema
|
|
1019
|
+
if (jsonSchema?.isDiscriminator) {
|
|
813
1020
|
const discriminator = jsonSchema.discriminatorAncestor.discriminator();
|
|
814
1021
|
const { propertyName } = discriminator;
|
|
815
1022
|
super.set("discriminator", {
|