@tsed/schema 7.86.3 → 7.87.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +9 -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 +10 -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,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAO,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,mBAAmB,EAAC,MAAM,6CAA6C,CAAC;AAEhF,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAGpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,eAAe;IAA/C;;QACI,WAAM,GAAmB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAqCtE,CAAC;IAnCC,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B;QACxD,OAAO,eAAe,CAAC,IAAI,CAAoB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;IAES,KAAK;QACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,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,UAAU,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,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC7B,MAAM,GAAG,UAAU,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,UAAU,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,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,CAsC7B;SAtCY,iBAAiB;AA4C9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ancestorsOf, classOf,
|
|
1
|
+
import { ancestorOf, ancestorsOf, classOf, isArray, isClass, isFunction, isObject, isPlainObject, isPrimitiveClass, nameOf, uniq, Hooks } from "@tsed/core";
|
|
2
|
+
import { VendorKeys } from "../constants/VendorKeys.js";
|
|
2
3
|
import { enumsRegistry } from "../registries/enumRegistries.js";
|
|
3
4
|
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
|
|
4
5
|
import { getComputedType } from "../utils/getComputedType.js";
|
|
5
6
|
import { getJsonType } from "../utils/getJsonType.js";
|
|
7
|
+
import { matchGroups } from "../utils/matchGroups.js";
|
|
6
8
|
import { serializeEnumValues } from "../utils/serializeEnumValues.js";
|
|
7
9
|
import { toJsonRegex } from "../utils/toJsonRegex.js";
|
|
8
10
|
import { Discriminator } from "./JsonDiscriminator.js";
|
|
@@ -14,6 +16,9 @@ function mapProperties(properties) {
|
|
|
14
16
|
}
|
|
15
17
|
return Object.entries(properties).reduce((properties, [key, schema]) => {
|
|
16
18
|
properties[toJsonRegex(key)] = mapToJsonSchema(schema);
|
|
19
|
+
if (schema instanceof JsonSchema) {
|
|
20
|
+
schema.propertyKey(toJsonRegex(key));
|
|
21
|
+
}
|
|
17
22
|
return properties;
|
|
18
23
|
}, {});
|
|
19
24
|
}
|
|
@@ -35,35 +40,83 @@ function mapToJsonSchema(item) {
|
|
|
35
40
|
}
|
|
36
41
|
return item;
|
|
37
42
|
}
|
|
43
|
+
function isEnum(type) {
|
|
44
|
+
return isObject(type) && !("toJSON" in type);
|
|
45
|
+
}
|
|
46
|
+
function mapGenerics(jsonSchema, generics) {
|
|
47
|
+
const genericLabels = jsonSchema.getGenericLabels();
|
|
48
|
+
if (!genericLabels) {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
const [types, ...nextTypes] = generics;
|
|
52
|
+
return types.reduce((mapping, type, index) => {
|
|
53
|
+
const label = genericLabels[index];
|
|
54
|
+
if (label) {
|
|
55
|
+
if (isEnum(type)) {
|
|
56
|
+
mapping[label] = [JsonSchema.from({ type: "string", enum: Object.values(type) })];
|
|
57
|
+
}
|
|
58
|
+
else if (nextTypes.length) {
|
|
59
|
+
const nextSchema = mapToJsonSchema(type);
|
|
60
|
+
mapping[label] = [nextSchema, mapGenerics(nextSchema, nextTypes)];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
mapping[label] = [mapToJsonSchema(type)];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return mapping;
|
|
67
|
+
}, {});
|
|
68
|
+
}
|
|
38
69
|
export class JsonSchema extends Map {
|
|
39
|
-
|
|
70
|
+
/**
|
|
71
|
+
* All required fields are stored here
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
#required;
|
|
75
|
+
/**
|
|
76
|
+
* Internal custom props
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
#vendors;
|
|
40
80
|
#discriminator;
|
|
41
|
-
#genericLabels;
|
|
42
|
-
#nestedGenerics;
|
|
43
81
|
#alias;
|
|
44
82
|
#itemSchema;
|
|
83
|
+
/**
|
|
84
|
+
* This flag is used to know if the schema is created to link property/param to a class schema.
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
#isLocalSchema;
|
|
45
88
|
#target;
|
|
46
|
-
#isGeneric;
|
|
47
89
|
#isCollection;
|
|
48
|
-
#
|
|
90
|
+
#useRefLabel;
|
|
91
|
+
#propertyKey;
|
|
49
92
|
constructor(obj = {}) {
|
|
50
93
|
super();
|
|
51
94
|
this.$kind = "schema";
|
|
52
95
|
this.$isJsonDocument = true;
|
|
53
96
|
this.$hooks = new Hooks();
|
|
54
|
-
this.$required = new Set();
|
|
55
97
|
this.$allow = [];
|
|
56
|
-
this.$forwardGroups = false;
|
|
57
98
|
this.$ignore = false;
|
|
58
99
|
this.isDiscriminatorKey = false;
|
|
59
100
|
this.isDiscriminator = false;
|
|
60
|
-
|
|
101
|
+
/**
|
|
102
|
+
* All required fields are stored here
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
this.#required = new Set();
|
|
106
|
+
/**
|
|
107
|
+
* Internal custom props
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
this.#vendors = new Map();
|
|
61
111
|
this.#discriminator = null;
|
|
62
|
-
this.#nestedGenerics = [];
|
|
63
112
|
this.#alias = new Map();
|
|
64
|
-
|
|
113
|
+
/**
|
|
114
|
+
* This flag is used to know if the schema is created to link property/param to a class schema.
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
this.#isLocalSchema = false;
|
|
65
118
|
this.#isCollection = false;
|
|
66
|
-
this.#
|
|
119
|
+
this.#useRefLabel = false;
|
|
67
120
|
if (obj) {
|
|
68
121
|
this.assign(obj);
|
|
69
122
|
}
|
|
@@ -71,32 +124,27 @@ export class JsonSchema extends Map {
|
|
|
71
124
|
get alias() {
|
|
72
125
|
return this.#alias;
|
|
73
126
|
}
|
|
74
|
-
get nestedGenerics() {
|
|
75
|
-
return this.#nestedGenerics;
|
|
76
|
-
}
|
|
77
|
-
set nestedGenerics(value) {
|
|
78
|
-
this.#nestedGenerics = value;
|
|
79
|
-
}
|
|
80
|
-
get genericLabels() {
|
|
81
|
-
return this.#genericLabels;
|
|
82
|
-
}
|
|
83
|
-
set genericLabels(value) {
|
|
84
|
-
this.#genericLabels = value;
|
|
85
|
-
}
|
|
86
127
|
get isClass() {
|
|
87
|
-
return isClass(this.class) && !
|
|
128
|
+
return isClass(this.class) && !this.isCollection;
|
|
88
129
|
}
|
|
89
130
|
/**
|
|
90
|
-
*
|
|
131
|
+
* The current schema is a collection
|
|
91
132
|
*/
|
|
92
133
|
get isCollection() {
|
|
93
134
|
return this.#isCollection;
|
|
94
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* The current schema is a reference to another schema
|
|
138
|
+
* to link property/param to a class schema (if the reference exists).
|
|
139
|
+
*/
|
|
140
|
+
get isLocalSchema() {
|
|
141
|
+
return this.#isLocalSchema;
|
|
142
|
+
}
|
|
95
143
|
/**
|
|
96
144
|
* Current schema is a generic
|
|
97
145
|
*/
|
|
98
146
|
get isGeneric() {
|
|
99
|
-
return this
|
|
147
|
+
return this.has(VendorKeys.GENERIC_LABEL);
|
|
100
148
|
}
|
|
101
149
|
get discriminatorAncestor() {
|
|
102
150
|
const ancestors = ancestorsOf(this.#target);
|
|
@@ -104,22 +152,27 @@ export class JsonSchema extends Map {
|
|
|
104
152
|
return ancestor && JsonEntityStore.from(ancestor).schema;
|
|
105
153
|
}
|
|
106
154
|
/**
|
|
107
|
-
*
|
|
155
|
+
* Return the itemSchema computed type.
|
|
156
|
+
* If the type is a function used for a recursive model,
|
|
157
|
+
* the function will be called to get the right type.
|
|
108
158
|
*/
|
|
109
|
-
get hasGenerics() {
|
|
110
|
-
return !!(this.nestedGenerics && this.nestedGenerics.length);
|
|
111
|
-
}
|
|
112
|
-
get genericType() {
|
|
113
|
-
return this.get("$ref");
|
|
114
|
-
}
|
|
115
159
|
get class() {
|
|
116
|
-
|
|
160
|
+
if (this.#isLocalSchema) {
|
|
161
|
+
return this.#itemSchema?.getTarget();
|
|
162
|
+
}
|
|
163
|
+
return getComputedType(this.#target);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Return the itemSchema computed type.
|
|
167
|
+
*/
|
|
168
|
+
get collectionClass() {
|
|
169
|
+
return this.isCollection && this.#itemSchema ? this.#itemSchema.class : this.class;
|
|
117
170
|
}
|
|
118
171
|
get canRef() {
|
|
119
|
-
return this.#
|
|
172
|
+
return this.#useRefLabel;
|
|
120
173
|
}
|
|
121
174
|
get isNullable() {
|
|
122
|
-
return this
|
|
175
|
+
return !!this.get("nullable");
|
|
123
176
|
}
|
|
124
177
|
get isReadOnly() {
|
|
125
178
|
return this.get("readOnly");
|
|
@@ -130,15 +183,105 @@ export class JsonSchema extends Map {
|
|
|
130
183
|
get hasDiscriminator() {
|
|
131
184
|
return !!this.#discriminator;
|
|
132
185
|
}
|
|
133
|
-
static from(
|
|
134
|
-
|
|
186
|
+
static from(item = {}) {
|
|
187
|
+
if (item instanceof JsonSchema) {
|
|
188
|
+
return item;
|
|
189
|
+
}
|
|
190
|
+
if (classOf(item) !== Object && isClass(item)) {
|
|
191
|
+
return JsonEntityStore.from(item).schema;
|
|
192
|
+
}
|
|
193
|
+
if (isPrimitiveClass(item)) {
|
|
194
|
+
return new JsonSchema({ type: item });
|
|
195
|
+
}
|
|
196
|
+
return new JsonSchema(item);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if the schema as key, #key or x-key
|
|
200
|
+
* @param key
|
|
201
|
+
*/
|
|
202
|
+
has(key) {
|
|
203
|
+
if (super.has(key)) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (super.has(`#${key}`)) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return this.#vendors.has(key);
|
|
210
|
+
}
|
|
211
|
+
get(key, defaultValue) {
|
|
212
|
+
if (this.#vendors.has(key)) {
|
|
213
|
+
return this.#vendors.get(key);
|
|
214
|
+
}
|
|
215
|
+
if (super.has(key)) {
|
|
216
|
+
return super.get(key);
|
|
217
|
+
}
|
|
218
|
+
if (super.has(`#${key}`)) {
|
|
219
|
+
return super.get(`#${key}`);
|
|
220
|
+
}
|
|
221
|
+
return defaultValue;
|
|
222
|
+
}
|
|
223
|
+
forwardGroups(bool = true) {
|
|
224
|
+
this.vendorKey(VendorKeys.FORWARD_GROUPS, bool);
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
groups(groups, isProperty) {
|
|
228
|
+
if (groups) {
|
|
229
|
+
this.vendorKey(VendorKeys.GROUPS, groups);
|
|
230
|
+
// this.customKey("x-groups", groups);
|
|
231
|
+
if (isProperty) {
|
|
232
|
+
this.$hooks.on("groups", (prev, givenGroups) => {
|
|
233
|
+
if (!prev) {
|
|
234
|
+
if (matchGroups(groups, givenGroups)) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return prev;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
groupsName(groupsName) {
|
|
245
|
+
groupsName && this.vendorKey(VendorKeys.GROUPS_NAME, groupsName);
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
allowedGroups(groups) {
|
|
249
|
+
groups && this.vendorKey(VendorKeys.ALLOWED_GROUPS, groups);
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Assign the Generic Labels used over a class or a schema.
|
|
254
|
+
* @param genericLabels
|
|
255
|
+
*/
|
|
256
|
+
genericLabels(genericLabels) {
|
|
257
|
+
this.vendorKey(VendorKeys.GENERIC_LABELS, genericLabels);
|
|
258
|
+
return this;
|
|
259
|
+
}
|
|
260
|
+
genericLabel(genericLabel) {
|
|
261
|
+
this.vendorKey(VendorKeys.GENERIC_LABEL, genericLabel);
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Assign the types of the generics that must be used for the property
|
|
266
|
+
* @param generics
|
|
267
|
+
*/
|
|
268
|
+
genericOf(...generics) {
|
|
269
|
+
const mapped = mapGenerics(this.#itemSchema || mapToJsonSchema(this.getTarget()), generics);
|
|
270
|
+
this.vendorKey(VendorKeys.GENERIC_OF, mapped);
|
|
271
|
+
return this;
|
|
135
272
|
}
|
|
136
273
|
nullable(value) {
|
|
137
|
-
this
|
|
274
|
+
this.vendorKey(VendorKeys.NULLABLE, value);
|
|
275
|
+
return this;
|
|
138
276
|
}
|
|
139
277
|
itemSchema(obj = {}) {
|
|
140
278
|
this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);
|
|
141
|
-
|
|
279
|
+
if (isPlainObject(obj)) {
|
|
280
|
+
this.#itemSchema.assign(obj);
|
|
281
|
+
}
|
|
282
|
+
if (!this.isCollection && this.#itemSchema?.isClass) {
|
|
283
|
+
this.#isLocalSchema = true;
|
|
284
|
+
}
|
|
142
285
|
return this.#itemSchema;
|
|
143
286
|
}
|
|
144
287
|
getAliasOf(property) {
|
|
@@ -172,7 +315,7 @@ export class JsonSchema extends Map {
|
|
|
172
315
|
* @param name
|
|
173
316
|
*/
|
|
174
317
|
label(name) {
|
|
175
|
-
this.#
|
|
318
|
+
this.#useRefLabel = true;
|
|
176
319
|
super.set("name", name);
|
|
177
320
|
return this;
|
|
178
321
|
}
|
|
@@ -224,6 +367,15 @@ export class JsonSchema extends Map {
|
|
|
224
367
|
discriminatorKey(propertyName) {
|
|
225
368
|
this.discriminator().propertyName = propertyName;
|
|
226
369
|
this.isDiscriminator = true;
|
|
370
|
+
const propertySchema = this.get("properties")[propertyName];
|
|
371
|
+
if (propertySchema) {
|
|
372
|
+
if (propertySchema.isCollection) {
|
|
373
|
+
propertySchema.itemSchema().isDiscriminatorKey = true;
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
propertySchema.isDiscriminatorKey = true;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
227
379
|
return this;
|
|
228
380
|
}
|
|
229
381
|
discriminatorValue(...values) {
|
|
@@ -367,8 +519,8 @@ export class JsonSchema extends Map {
|
|
|
367
519
|
*/
|
|
368
520
|
required(required = true) {
|
|
369
521
|
if (isArray(required)) {
|
|
370
|
-
this
|
|
371
|
-
required.forEach((value) => this
|
|
522
|
+
this.#required.clear();
|
|
523
|
+
required.forEach((value) => this.#required.add(value));
|
|
372
524
|
}
|
|
373
525
|
else {
|
|
374
526
|
const schema = this.clone();
|
|
@@ -381,15 +533,18 @@ export class JsonSchema extends Map {
|
|
|
381
533
|
return this;
|
|
382
534
|
}
|
|
383
535
|
addRequired(property) {
|
|
384
|
-
this
|
|
536
|
+
this.#required.add(property);
|
|
385
537
|
return this;
|
|
386
538
|
}
|
|
387
539
|
removeRequired(property) {
|
|
388
|
-
this
|
|
540
|
+
this.#required.delete(property);
|
|
389
541
|
return this;
|
|
390
542
|
}
|
|
391
543
|
isRequired(property) {
|
|
392
|
-
return this
|
|
544
|
+
return this.#required.has(property);
|
|
545
|
+
}
|
|
546
|
+
getRequiredFields() {
|
|
547
|
+
return [...this.#required];
|
|
393
548
|
}
|
|
394
549
|
/**
|
|
395
550
|
* This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.
|
|
@@ -507,7 +662,12 @@ export class JsonSchema extends Map {
|
|
|
507
662
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
|
508
663
|
*/
|
|
509
664
|
oneOf(oneOf) {
|
|
510
|
-
this.
|
|
665
|
+
if (this.isCollection) {
|
|
666
|
+
this.itemSchema().oneOf(oneOf);
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
this.setManyOf("oneOf", oneOf);
|
|
670
|
+
}
|
|
511
671
|
return this;
|
|
512
672
|
}
|
|
513
673
|
/**
|
|
@@ -605,7 +765,7 @@ export class JsonSchema extends Map {
|
|
|
605
765
|
case "map":
|
|
606
766
|
case Map:
|
|
607
767
|
super.set("type", getJsonType(type));
|
|
608
|
-
this
|
|
768
|
+
this.target(type);
|
|
609
769
|
this.#isCollection = true;
|
|
610
770
|
if (!this.has("additionalProperties")) {
|
|
611
771
|
super.set("additionalProperties", this.itemSchema({}));
|
|
@@ -614,7 +774,7 @@ export class JsonSchema extends Map {
|
|
|
614
774
|
case "array":
|
|
615
775
|
case Array:
|
|
616
776
|
super.set("type", getJsonType(type));
|
|
617
|
-
this
|
|
777
|
+
this.target(type);
|
|
618
778
|
this.#isCollection = true;
|
|
619
779
|
if (!this.has("items")) {
|
|
620
780
|
super.set("items", this.itemSchema({}));
|
|
@@ -623,7 +783,7 @@ export class JsonSchema extends Map {
|
|
|
623
783
|
case "set":
|
|
624
784
|
case Set:
|
|
625
785
|
super.set("type", getJsonType(type));
|
|
626
|
-
this
|
|
786
|
+
this.target(type);
|
|
627
787
|
this.#isCollection = true;
|
|
628
788
|
this.uniqueItems(true);
|
|
629
789
|
if (!this.has("items")) {
|
|
@@ -643,7 +803,7 @@ export class JsonSchema extends Map {
|
|
|
643
803
|
case Number:
|
|
644
804
|
case String:
|
|
645
805
|
super.set("type", getJsonType(type));
|
|
646
|
-
this
|
|
806
|
+
this.target(type);
|
|
647
807
|
if (!this.has("properties")) {
|
|
648
808
|
super.set("properties", {});
|
|
649
809
|
}
|
|
@@ -651,7 +811,7 @@ export class JsonSchema extends Map {
|
|
|
651
811
|
default:
|
|
652
812
|
if (isClass(type) || isFunction(type)) {
|
|
653
813
|
super.set("type", undefined);
|
|
654
|
-
this
|
|
814
|
+
this.target(type);
|
|
655
815
|
if (!this.has("properties")) {
|
|
656
816
|
super.set("properties", {});
|
|
657
817
|
}
|
|
@@ -659,8 +819,7 @@ export class JsonSchema extends Map {
|
|
|
659
819
|
else {
|
|
660
820
|
const jsonType = getJsonType(type);
|
|
661
821
|
if (jsonType === "generic") {
|
|
662
|
-
this
|
|
663
|
-
super.set("$ref", type);
|
|
822
|
+
this.genericLabel(type);
|
|
664
823
|
}
|
|
665
824
|
else {
|
|
666
825
|
super.set("type", jsonType);
|
|
@@ -708,6 +867,10 @@ export class JsonSchema extends Map {
|
|
|
708
867
|
super.set(`#${key}`, value);
|
|
709
868
|
return this;
|
|
710
869
|
}
|
|
870
|
+
vendorKey(key, value) {
|
|
871
|
+
this.#vendors.set(key, value);
|
|
872
|
+
return this;
|
|
873
|
+
}
|
|
711
874
|
toObject(options) {
|
|
712
875
|
return this.toJSON(options);
|
|
713
876
|
}
|
|
@@ -722,21 +885,16 @@ export class JsonSchema extends Map {
|
|
|
722
885
|
if (obj instanceof JsonSchema) {
|
|
723
886
|
this.$selfRequired = obj.$selfRequired;
|
|
724
887
|
this.$allow.push(...obj.$allow);
|
|
725
|
-
obj
|
|
726
|
-
|
|
727
|
-
|
|
888
|
+
this.#required = new Set(obj.#required.keys());
|
|
889
|
+
this.#alias = new Map(this.#alias.entries());
|
|
890
|
+
this.#vendors = new Map(obj.#vendors.entries());
|
|
728
891
|
this.#discriminator = this.#discriminator ? new Discriminator(this.#discriminator) : null;
|
|
729
892
|
this.isDiscriminator = obj.isDiscriminator;
|
|
730
893
|
this.isDiscriminatorKey = obj.isDiscriminatorKey;
|
|
731
|
-
this.#
|
|
732
|
-
this.#alias = new Map(this.#alias.entries());
|
|
733
|
-
obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);
|
|
734
|
-
this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);
|
|
894
|
+
this.#useRefLabel = obj.#useRefLabel;
|
|
735
895
|
this.#target = obj.#target;
|
|
736
|
-
this.#isGeneric = obj.#isGeneric;
|
|
737
896
|
this.#isCollection = obj.#isCollection;
|
|
738
|
-
this.#
|
|
739
|
-
this.#nullable = obj.#nullable;
|
|
897
|
+
this.#isLocalSchema = obj.#isLocalSchema;
|
|
740
898
|
super.set("type", obj.get("type"));
|
|
741
899
|
}
|
|
742
900
|
return this;
|
|
@@ -750,17 +908,6 @@ export class JsonSchema extends Map {
|
|
|
750
908
|
}
|
|
751
909
|
return this;
|
|
752
910
|
}
|
|
753
|
-
/**
|
|
754
|
-
* Return the itemSchema computed type.
|
|
755
|
-
* If the type is a function used for recursive model,
|
|
756
|
-
* the function will be called to get the right type.
|
|
757
|
-
*/
|
|
758
|
-
getComputedType() {
|
|
759
|
-
return getComputedType(this.#target);
|
|
760
|
-
}
|
|
761
|
-
getComputedItemType() {
|
|
762
|
-
return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();
|
|
763
|
-
}
|
|
764
911
|
/**
|
|
765
912
|
* Return the Json type as string
|
|
766
913
|
*/
|
|
@@ -770,24 +917,84 @@ export class JsonSchema extends Map {
|
|
|
770
917
|
return o.getJsonType();
|
|
771
918
|
});
|
|
772
919
|
}
|
|
773
|
-
return this.get("type") || getJsonType(this.
|
|
920
|
+
return this.get("type") || getJsonType(this.class);
|
|
774
921
|
}
|
|
775
922
|
getTarget() {
|
|
776
923
|
return this.#target;
|
|
777
924
|
}
|
|
925
|
+
getAllowedGroups() {
|
|
926
|
+
return this.get(VendorKeys.ALLOWED_GROUPS);
|
|
927
|
+
}
|
|
928
|
+
getAllowedRequiredValues() {
|
|
929
|
+
return this.$allow;
|
|
930
|
+
}
|
|
931
|
+
getGroups() {
|
|
932
|
+
return this.get(VendorKeys.GROUPS);
|
|
933
|
+
}
|
|
934
|
+
getGroupsName() {
|
|
935
|
+
return this.get(VendorKeys.GROUPS_NAME);
|
|
936
|
+
}
|
|
778
937
|
/**
|
|
779
938
|
* Get the symbolic name of the entity
|
|
780
939
|
*/
|
|
781
940
|
getName() {
|
|
782
|
-
return this.get("name") || (isClass(this.#target) ? nameOf(classOf(this.
|
|
941
|
+
return this.get("name") || (isClass(this.#target) ? nameOf(classOf(this.class)) : "");
|
|
783
942
|
}
|
|
784
943
|
clone() {
|
|
785
944
|
return new JsonSchema(this);
|
|
786
945
|
}
|
|
946
|
+
getGenericLabels() {
|
|
947
|
+
const labels = this.get(VendorKeys.GENERIC_LABELS);
|
|
948
|
+
if (this.isClass && !labels) {
|
|
949
|
+
const ancestor = ancestorOf(this.class);
|
|
950
|
+
return ancestor === Object ? undefined : JsonSchema.from(ancestor).getGenericLabels();
|
|
951
|
+
}
|
|
952
|
+
return this.get(VendorKeys.GENERIC_LABELS);
|
|
953
|
+
}
|
|
954
|
+
getGenericOf() {
|
|
955
|
+
return this.get(VendorKeys.GENERIC_OF);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Returns the reference schema for class-based schemas.
|
|
959
|
+
* Used to get the original schema definition when this schema is a local reference.
|
|
960
|
+
* @returns The reference schema or undefined if not applicable
|
|
961
|
+
*/
|
|
962
|
+
getRefSchema() {
|
|
963
|
+
if (!this.isLocalSchema && this.isClass) {
|
|
964
|
+
const refSchema = JsonSchema.from(this.class);
|
|
965
|
+
if (refSchema !== this) {
|
|
966
|
+
return refSchema;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
propertyKey(s) {
|
|
971
|
+
this.#propertyKey = s;
|
|
972
|
+
return this;
|
|
973
|
+
}
|
|
974
|
+
getPropertyKey() {
|
|
975
|
+
return this.#propertyKey;
|
|
976
|
+
}
|
|
977
|
+
target(target) {
|
|
978
|
+
if (target === "object") {
|
|
979
|
+
this.#target = Object;
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
this.#target = target;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
isRequiredValue(property, value) {
|
|
986
|
+
if (this.isRequired(property) && [undefined, null, ""].includes(value)) {
|
|
987
|
+
const propertySchema = this.get("properties")?.[property];
|
|
988
|
+
if (propertySchema) {
|
|
989
|
+
return !propertySchema.getAllowedRequiredValues().includes(value);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
787
994
|
setManyOf(keyword, value) {
|
|
788
995
|
let resolved = value
|
|
789
996
|
.filter((o) => {
|
|
790
|
-
if (o
|
|
997
|
+
if (o && "type" in o && o.type === "null") {
|
|
791
998
|
this.nullable(true);
|
|
792
999
|
return false;
|
|
793
1000
|
}
|
|
@@ -806,7 +1013,7 @@ export class JsonSchema extends Map {
|
|
|
806
1013
|
}
|
|
807
1014
|
super.set(keyword, resolved);
|
|
808
1015
|
const jsonSchema = resolved[0];
|
|
809
|
-
if (jsonSchema
|
|
1016
|
+
if (jsonSchema?.isDiscriminator) {
|
|
810
1017
|
const discriminator = jsonSchema.discriminatorAncestor.discriminator();
|
|
811
1018
|
const { propertyName } = discriminator;
|
|
812
1019
|
super.set("discriminator", {
|