@skmtc/core 0.39.0 → 0.41.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/esm/context/CoreContext.js +22 -8
- package/esm/context/GenerateContext.d.ts +6 -5
- package/esm/context/GenerateContext.js +112 -38
- package/esm/context/ParseContext.d.ts +18 -1
- package/esm/context/ParseContext.js +102 -3
- package/esm/context/generateTypes.d.ts +33 -4
- package/esm/context/generateTypes.js +4 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- package/esm/context/tryParseAt.d.ts +4 -1
- package/esm/context/tryParseAt.js +10 -3
- package/esm/dsl/CustomValue.d.ts +4 -0
- package/esm/dsl/CustomValue.js +8 -0
- package/esm/dsl/Definition.d.ts +10 -0
- package/esm/dsl/Definition.js +14 -0
- package/esm/dsl/PendingDefinition.d.ts +47 -0
- package/esm/dsl/PendingDefinition.js +83 -0
- package/esm/dsl/model/ModelDriver.d.ts +55 -1
- package/esm/dsl/model/ModelDriver.js +228 -51
- package/esm/dsl/model/toModelEntry.d.ts +1 -1
- package/esm/dsl/model/toModelEntry.js +1 -1
- package/esm/dsl/model/types.d.ts +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/esm/dsl/webhook/WebhookDriver.js +1 -4
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
- package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/esm/enrichments/parseEnrichmentValue.js +32 -0
- package/esm/enrichments/readEnrichments.d.ts +5 -5
- package/esm/enrichments/readEnrichments.js +17 -7
- package/esm/helpers/collateExamples.js +15 -5
- package/esm/helpers/refFns.d.ts +6 -2
- package/esm/helpers/refFns.js +24 -7
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/oas/array/Array.d.ts +19 -0
- package/esm/oas/array/Array.js +47 -0
- package/esm/oas/boolean/Boolean.d.ts +19 -0
- package/esm/oas/boolean/Boolean.js +51 -8
- package/esm/oas/example/Example.d.ts +4 -0
- package/esm/oas/example/Example.js +8 -0
- package/esm/oas/header/Header.d.ts +4 -0
- package/esm/oas/header/Header.js +8 -0
- package/esm/oas/integer/Integer.d.ts +19 -0
- package/esm/oas/integer/Integer.js +49 -0
- package/esm/oas/link/Link.d.ts +4 -0
- package/esm/oas/link/Link.js +8 -0
- package/esm/oas/number/Number.d.ts +19 -0
- package/esm/oas/number/Number.js +49 -0
- package/esm/oas/object/Object.d.ts +19 -0
- package/esm/oas/object/Object.js +68 -18
- package/esm/oas/operation/Operation.d.ts +8 -1
- package/esm/oas/operation/Operation.js +18 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/esm/oas/operation/toEffectiveParameters.js +42 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/DanglingRefError.d.ts +22 -0
- package/esm/oas/ref/DanglingRefError.js +33 -0
- package/esm/oas/ref/Ref.d.ts +152 -25
- package/esm/oas/ref/Ref.js +414 -26
- package/esm/oas/requestBody/RequestBody.d.ts +4 -0
- package/esm/oas/requestBody/RequestBody.js +8 -0
- package/esm/oas/response/Response.d.ts +4 -0
- package/esm/oas/response/Response.js +8 -0
- package/esm/oas/schema/siblings.d.ts +127 -0
- package/esm/oas/schema/siblings.js +250 -0
- package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
- package/esm/oas/string/String.d.ts +19 -0
- package/esm/oas/string/String.js +47 -0
- package/esm/oas/union/Union.d.ts +32 -0
- package/esm/oas/union/Union.js +111 -0
- package/esm/oas/unknown/Unknown.d.ts +18 -0
- package/esm/oas/unknown/Unknown.js +38 -0
- package/esm/oas/void/Void.d.ts +4 -0
- package/esm/oas/void/Void.js +8 -0
- package/esm/oas/webhook/Webhook.d.ts +2 -2
- package/esm/oas/webhook/Webhook.js +4 -5
- package/esm/parse/allOfSystem.d.ts +32 -0
- package/esm/parse/allOfSystem.js +30 -0
- package/esm/parse/anyOfSystem.d.ts +68 -0
- package/esm/parse/anyOfSystem.js +107 -0
- package/esm/parse/securityRequirements.d.ts +6 -0
- package/esm/parse/securityRequirements.js +8 -0
- package/esm/parse/toSiblingKeywords.d.ts +28 -0
- package/esm/parse/toSiblingKeywords.js +109 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
- package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
- package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +6 -3
- package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +6 -3
- package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +6 -3
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +44 -0
- package/esm/types/Settings.js +9 -0
- package/package.json +5 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +6 -5
- package/script/context/GenerateContext.js +112 -38
- package/script/context/ParseContext.d.ts +18 -1
- package/script/context/ParseContext.js +102 -3
- package/script/context/generateTypes.d.ts +33 -4
- package/script/context/generateTypes.js +4 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- package/script/context/tryParseAt.d.ts +4 -1
- package/script/context/tryParseAt.js +10 -3
- package/script/dsl/CustomValue.d.ts +4 -0
- package/script/dsl/CustomValue.js +8 -0
- package/script/dsl/Definition.d.ts +10 -0
- package/script/dsl/Definition.js +14 -0
- package/script/dsl/PendingDefinition.d.ts +47 -0
- package/script/dsl/PendingDefinition.js +87 -0
- package/script/dsl/model/ModelDriver.d.ts +55 -1
- package/script/dsl/model/ModelDriver.js +231 -52
- package/script/dsl/model/toModelEntry.d.ts +1 -1
- package/script/dsl/model/toModelEntry.js +1 -1
- package/script/dsl/model/types.d.ts +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/script/dsl/webhook/WebhookDriver.js +1 -4
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
- package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/script/enrichments/parseEnrichmentValue.js +69 -0
- package/script/enrichments/readEnrichments.d.ts +5 -5
- package/script/enrichments/readEnrichments.js +17 -40
- package/script/helpers/collateExamples.js +15 -5
- package/script/helpers/refFns.d.ts +6 -2
- package/script/helpers/refFns.js +24 -7
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/oas/array/Array.d.ts +19 -0
- package/script/oas/array/Array.js +47 -0
- package/script/oas/boolean/Boolean.d.ts +19 -0
- package/script/oas/boolean/Boolean.js +51 -8
- package/script/oas/example/Example.d.ts +4 -0
- package/script/oas/example/Example.js +8 -0
- package/script/oas/header/Header.d.ts +4 -0
- package/script/oas/header/Header.js +8 -0
- package/script/oas/integer/Integer.d.ts +19 -0
- package/script/oas/integer/Integer.js +49 -0
- package/script/oas/link/Link.d.ts +4 -0
- package/script/oas/link/Link.js +8 -0
- package/script/oas/number/Number.d.ts +19 -0
- package/script/oas/number/Number.js +49 -0
- package/script/oas/object/Object.d.ts +19 -0
- package/script/oas/object/Object.js +68 -18
- package/script/oas/operation/Operation.d.ts +8 -1
- package/script/oas/operation/Operation.js +18 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/script/oas/operation/toEffectiveParameters.js +47 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/DanglingRefError.d.ts +22 -0
- package/script/oas/ref/DanglingRefError.js +37 -0
- package/script/oas/ref/Ref.d.ts +152 -25
- package/script/oas/ref/Ref.js +414 -26
- package/script/oas/requestBody/RequestBody.d.ts +4 -0
- package/script/oas/requestBody/RequestBody.js +8 -0
- package/script/oas/response/Response.d.ts +4 -0
- package/script/oas/response/Response.js +8 -0
- package/script/oas/schema/siblings.d.ts +127 -0
- package/script/oas/schema/siblings.js +305 -0
- package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/script/oas/securitySchemes/SecurityScheme.js +32 -0
- package/script/oas/string/String.d.ts +19 -0
- package/script/oas/string/String.js +47 -0
- package/script/oas/union/Union.d.ts +32 -0
- package/script/oas/union/Union.js +111 -0
- package/script/oas/unknown/Unknown.d.ts +18 -0
- package/script/oas/unknown/Unknown.js +38 -0
- package/script/oas/void/Void.d.ts +4 -0
- package/script/oas/void/Void.js +8 -0
- package/script/oas/webhook/Webhook.d.ts +2 -2
- package/script/oas/webhook/Webhook.js +4 -5
- package/script/parse/allOfSystem.d.ts +32 -0
- package/script/parse/allOfSystem.js +35 -0
- package/script/parse/anyOfSystem.d.ts +68 -0
- package/script/parse/anyOfSystem.js +116 -0
- package/script/parse/securityRequirements.d.ts +6 -0
- package/script/parse/securityRequirements.js +8 -0
- package/script/parse/toSiblingKeywords.d.ts +28 -0
- package/script/parse/toSiblingKeywords.js +146 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
- package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
- package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
- package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +6 -3
- package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +6 -3
- package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +6 -3
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +44 -0
- package/script/types/Settings.js +10 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { OasSchema } from './Schema.js';
|
|
2
|
+
import type { OasRef } from '../ref/Ref.js';
|
|
3
|
+
/**
|
|
4
|
+
* The keywords next to a reference in a one-member `allOf`
|
|
5
|
+
* (`{ allOf: [{ $ref }], minLength: 3, description: '…' }`), the use-site
|
|
6
|
+
* flags `nullable`, `readOnly` and `writeOnly` among them: the fields a
|
|
7
|
+
* reference adds at its site (`RefFields`).
|
|
8
|
+
*
|
|
9
|
+
* The parser reads them without knowing the target's type: the reference
|
|
10
|
+
* stays lazy. Each schema class's `clone(ref)` takes the keywords its type
|
|
11
|
+
* has ({@link SIBLINGS_BY_TYPE}). A value whose type depends on the target
|
|
12
|
+
* (`example`, `default`, `enums`, `format`) is kept as written, and `clone`
|
|
13
|
+
* takes it only when it fits. {@link toSkippedSiblings} names the keywords
|
|
14
|
+
* `clone` leaves out, for a generator to log.
|
|
15
|
+
*/
|
|
16
|
+
export type SiblingKeywords = {
|
|
17
|
+
/**
|
|
18
|
+
* Use-site nullability. A `$ref` is a per-reference node: the same
|
|
19
|
+
* refName may be referenced nullable at one site and non-nullable at
|
|
20
|
+
* another, so nullability rides the reference, not the shared referent.
|
|
21
|
+
* Set by the single-member `oneOf`/`anyOf` collapse for the 3.1
|
|
22
|
+
* `oneOf:[{$ref},{type:null}]` idiom, and next to a one-member `allOf`.
|
|
23
|
+
* Generators read it off the reference (`'nullable' in schema ?
|
|
24
|
+
* schema.nullable`) to render `Foo | null`, while `ModelDriver` builds the
|
|
25
|
+
* un-nullable shared model from the refName.
|
|
26
|
+
*/
|
|
27
|
+
nullable?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Use-site `readOnly`: set where a property marks a reference read-only,
|
|
30
|
+
* `{ allOf: [{ $ref }], readOnly: true }` (the 3.0 idiom, as keywords next
|
|
31
|
+
* to a bare `$ref` are ignored there). Like `nullable`, it rides the
|
|
32
|
+
* reference: the shared model is not read-only everywhere. Read it through
|
|
33
|
+
* `isReadOnly`, which also looks at what the reference points to.
|
|
34
|
+
*/
|
|
35
|
+
readOnly?: boolean;
|
|
36
|
+
/** Use-site `writeOnly`, as {@link readOnly}. */
|
|
37
|
+
writeOnly?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The `type` written next to the reference, merged in from the schema that
|
|
40
|
+
* holds the one-member `allOf`. It must agree with the target's; the copy
|
|
41
|
+
* always has the target's type. Not `type`, which on an `OasRef` is `'ref'`.
|
|
42
|
+
*/
|
|
43
|
+
_type?: unknown;
|
|
44
|
+
title?: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
deprecated?: boolean;
|
|
47
|
+
example?: unknown;
|
|
48
|
+
default?: unknown;
|
|
49
|
+
enums?: unknown[];
|
|
50
|
+
extensionFields?: Record<string, unknown>;
|
|
51
|
+
format?: string;
|
|
52
|
+
minLength?: number;
|
|
53
|
+
maxLength?: number;
|
|
54
|
+
pattern?: string;
|
|
55
|
+
multipleOf?: number;
|
|
56
|
+
minimum?: number;
|
|
57
|
+
maximum?: number;
|
|
58
|
+
exclusiveMinimum?: boolean;
|
|
59
|
+
exclusiveMaximum?: boolean;
|
|
60
|
+
minItems?: number;
|
|
61
|
+
maxItems?: number;
|
|
62
|
+
uniqueItems?: boolean;
|
|
63
|
+
properties?: Record<string, OasSchema | OasRef<'schema'>>;
|
|
64
|
+
required?: string[];
|
|
65
|
+
additionalProperties?: boolean | OasSchema | OasRef<'schema'>;
|
|
66
|
+
minProperties?: number;
|
|
67
|
+
maxProperties?: number;
|
|
68
|
+
};
|
|
69
|
+
/** A keyword `clone` can apply. `_type` only has to agree. */
|
|
70
|
+
export type SiblingKeyword = Exclude<keyof SiblingKeywords, '_type'>;
|
|
71
|
+
/** The keywords each schema class's `clone` takes: the fields its type has. */
|
|
72
|
+
export declare const SIBLINGS_BY_TYPE: Record<OasSchema['type'], SiblingKeyword[]>;
|
|
73
|
+
/**
|
|
74
|
+
* The keywords of `over` merged over those of `base`, for a reference copied
|
|
75
|
+
* with what another site adds (`OasRef.clone`): a flag set on either stays
|
|
76
|
+
* set, a keyword `over` sets wins, extension fields and `properties` merge,
|
|
77
|
+
* and `required` names add up, as each schema class's `clone` merges them
|
|
78
|
+
* into a schema.
|
|
79
|
+
*/
|
|
80
|
+
export declare const mergeSiblingKeywords: (base: SiblingKeywords, over: SiblingKeywords | undefined) => SiblingKeywords;
|
|
81
|
+
/** Whether `siblings` holds any keyword. */
|
|
82
|
+
export declare const hasSiblingKeywords: (siblings: SiblingKeywords) => boolean;
|
|
83
|
+
/** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
|
|
84
|
+
export declare const changesTarget: (copy: OasSchema, target: OasSchema, siblings: SiblingKeywords) => boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the keywords next to a reference change which values `target`
|
|
87
|
+
* accepts at that site (`minLength` next to a string, `properties` next to an
|
|
88
|
+
* object), not only how it is described (`description`, `deprecated`,
|
|
89
|
+
* `default`, `x-*`). The engine behind `OasRef.hasValueSiblings`.
|
|
90
|
+
*/
|
|
91
|
+
export declare const changesValues: (copy: OasSchema, target: OasSchema, siblings: SiblingKeywords) => boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The keywords next to a reference that `clone` leaves out for `target`, by
|
|
94
|
+
* their names in the document: one its type does not have (`minLength` next
|
|
95
|
+
* to an array), a `type` that disagrees with the target's, and an `example`,
|
|
96
|
+
* `default`, `enum` or `format` whose value does not fit. `nullable` says
|
|
97
|
+
* whether the site takes `null` among the `enum` members. The engine behind
|
|
98
|
+
* `OasRef.toSkippedSiblings`.
|
|
99
|
+
*/
|
|
100
|
+
export declare const toSkippedSiblings: (target: OasSchema, siblings: SiblingKeywords, nullable: boolean | undefined) => string[];
|
|
101
|
+
/** The annotations of `target` with those of `siblings` applied: a sibling's value wins, and extension fields merge. */
|
|
102
|
+
export declare const toSiblingAnnotations: (target: OasSchema, siblings: SiblingKeywords | undefined) => {
|
|
103
|
+
title: string | undefined;
|
|
104
|
+
description: string | undefined;
|
|
105
|
+
extensionFields: {
|
|
106
|
+
[x: string]: unknown;
|
|
107
|
+
} | undefined;
|
|
108
|
+
};
|
|
109
|
+
/** The value checks the parser makes for `example`, `default` and each `enum` member, by type. */
|
|
110
|
+
export declare const isStringValue: (value: unknown) => value is string;
|
|
111
|
+
export declare const isNumberValue: (value: unknown) => value is number;
|
|
112
|
+
export declare const isIntegerValue: (value: unknown) => value is number;
|
|
113
|
+
export declare const isBooleanValue: (value: unknown) => value is boolean;
|
|
114
|
+
export declare const isArrayValue: (value: unknown) => value is unknown[];
|
|
115
|
+
export declare const isObjectValue: (value: unknown) => value is Record<string, unknown>;
|
|
116
|
+
/** {@link isStringValue} and the others, keyed by the type they check for. A union or unknown takes any value. */
|
|
117
|
+
export declare const VALUE_CHECKS: Record<OasSchema['type'], (value: unknown) => boolean>;
|
|
118
|
+
/** The formats a number and an integer take. A string takes any format. */
|
|
119
|
+
export declare const isNumberFormat: (value: unknown) => value is "float" | "double";
|
|
120
|
+
export declare const isIntegerFormat: (value: unknown) => value is "int32" | "int64";
|
|
121
|
+
/** `value` when it passes `check`, else `undefined`: for `example`, `default` and `format`. */
|
|
122
|
+
export declare const toSiblingValue: <T>(value: unknown, check: (value: unknown) => value is T) => T | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* `enums` when every member passes `check`, or is `null` at a nullable site,
|
|
125
|
+
* else `undefined`. The parser reports the members that do not.
|
|
126
|
+
*/
|
|
127
|
+
export declare const toSiblingEnums: <T>(enums: unknown[] | undefined, check: (value: unknown) => value is T, nullable: boolean | undefined) => (T | null)[] | undefined;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import isEqual from 'lodash-es/isEqual.js';
|
|
3
|
+
import { DanglingRefError } from '../ref/DanglingRefError.js';
|
|
4
|
+
import { numberFormat } from '../number/number-types.js';
|
|
5
|
+
import { integerFormat } from '../integer/integer-types.js';
|
|
6
|
+
/**
|
|
7
|
+
* The use-site flags, taken by every type, so they are never reported as
|
|
8
|
+
* left out. A union's or unknown's copy has no `readOnly` or `writeOnly`
|
|
9
|
+
* field, but the reference still answers `isReadOnly()` and
|
|
10
|
+
* `isWriteOnly()` from its own flag.
|
|
11
|
+
*/
|
|
12
|
+
const FLAGS = ['nullable', 'readOnly', 'writeOnly'];
|
|
13
|
+
const DESCRIBING = [...FLAGS, 'title', 'description', 'extensionFields', 'example'];
|
|
14
|
+
const NUMERIC = [
|
|
15
|
+
'deprecated',
|
|
16
|
+
'default',
|
|
17
|
+
'enums',
|
|
18
|
+
'format',
|
|
19
|
+
'multipleOf',
|
|
20
|
+
'minimum',
|
|
21
|
+
'maximum',
|
|
22
|
+
'exclusiveMinimum',
|
|
23
|
+
'exclusiveMaximum'
|
|
24
|
+
];
|
|
25
|
+
/** The keywords each schema class's `clone` takes: the fields its type has. */
|
|
26
|
+
export const SIBLINGS_BY_TYPE = {
|
|
27
|
+
string: [...DESCRIBING, 'deprecated', 'default', 'enums', 'format', 'minLength', 'maxLength', 'pattern'],
|
|
28
|
+
number: [...DESCRIBING, ...NUMERIC],
|
|
29
|
+
integer: [...DESCRIBING, ...NUMERIC],
|
|
30
|
+
boolean: [...DESCRIBING, 'deprecated', 'default', 'enums'],
|
|
31
|
+
array: [...DESCRIBING, 'deprecated', 'default', 'enums', 'minItems', 'maxItems', 'uniqueItems'],
|
|
32
|
+
object: [
|
|
33
|
+
...DESCRIBING,
|
|
34
|
+
'deprecated',
|
|
35
|
+
'default',
|
|
36
|
+
'enums',
|
|
37
|
+
'properties',
|
|
38
|
+
'required',
|
|
39
|
+
'additionalProperties',
|
|
40
|
+
'minProperties',
|
|
41
|
+
'maxProperties'
|
|
42
|
+
],
|
|
43
|
+
union: [...DESCRIBING, 'default'],
|
|
44
|
+
unknown: DESCRIBING
|
|
45
|
+
};
|
|
46
|
+
/** Every keyword `clone` can apply, for any type. */
|
|
47
|
+
const SIBLING_KEYWORDS = [...new Set(Object.values(SIBLINGS_BY_TYPE).flat())];
|
|
48
|
+
/**
|
|
49
|
+
* The keywords of `over` merged over those of `base`, for a reference copied
|
|
50
|
+
* with what another site adds (`OasRef.clone`): a flag set on either stays
|
|
51
|
+
* set, a keyword `over` sets wins, extension fields and `properties` merge,
|
|
52
|
+
* and `required` names add up, as each schema class's `clone` merges them
|
|
53
|
+
* into a schema.
|
|
54
|
+
*/
|
|
55
|
+
export const mergeSiblingKeywords = (base, over) => ({
|
|
56
|
+
nullable: base.nullable || over?.nullable || undefined,
|
|
57
|
+
readOnly: base.readOnly || over?.readOnly || undefined,
|
|
58
|
+
writeOnly: base.writeOnly || over?.writeOnly || undefined,
|
|
59
|
+
_type: over?._type ?? base._type,
|
|
60
|
+
title: over?.title ?? base.title,
|
|
61
|
+
description: over?.description ?? base.description,
|
|
62
|
+
deprecated: over?.deprecated ?? base.deprecated,
|
|
63
|
+
example: over?.example ?? base.example,
|
|
64
|
+
default: over?.default ?? base.default,
|
|
65
|
+
enums: over?.enums ?? base.enums,
|
|
66
|
+
extensionFields: base.extensionFields === undefined && over?.extensionFields === undefined
|
|
67
|
+
? undefined
|
|
68
|
+
: { ...base.extensionFields, ...over?.extensionFields },
|
|
69
|
+
format: over?.format ?? base.format,
|
|
70
|
+
minLength: over?.minLength ?? base.minLength,
|
|
71
|
+
maxLength: over?.maxLength ?? base.maxLength,
|
|
72
|
+
pattern: over?.pattern ?? base.pattern,
|
|
73
|
+
multipleOf: over?.multipleOf ?? base.multipleOf,
|
|
74
|
+
minimum: over?.minimum ?? base.minimum,
|
|
75
|
+
maximum: over?.maximum ?? base.maximum,
|
|
76
|
+
exclusiveMinimum: over?.exclusiveMinimum ?? base.exclusiveMinimum,
|
|
77
|
+
exclusiveMaximum: over?.exclusiveMaximum ?? base.exclusiveMaximum,
|
|
78
|
+
minItems: over?.minItems ?? base.minItems,
|
|
79
|
+
maxItems: over?.maxItems ?? base.maxItems,
|
|
80
|
+
uniqueItems: over?.uniqueItems ?? base.uniqueItems,
|
|
81
|
+
properties: over?.properties === undefined ? base.properties : { ...base.properties, ...over.properties },
|
|
82
|
+
required: over?.required === undefined ? base.required : [...new Set([...(base.required ?? []), ...over.required])],
|
|
83
|
+
additionalProperties: over?.additionalProperties ?? base.additionalProperties,
|
|
84
|
+
minProperties: over?.minProperties ?? base.minProperties,
|
|
85
|
+
maxProperties: over?.maxProperties ?? base.maxProperties
|
|
86
|
+
});
|
|
87
|
+
/** Whether `siblings` holds any keyword. */
|
|
88
|
+
export const hasSiblingKeywords = (siblings) => siblings._type !== undefined || SIBLING_KEYWORDS.some(keyword => siblings[keyword] !== undefined);
|
|
89
|
+
/** The keywords that change which values a site accepts, not only how it is described. */
|
|
90
|
+
const VALUE_KEYWORDS = [
|
|
91
|
+
'enums',
|
|
92
|
+
'format',
|
|
93
|
+
'minLength',
|
|
94
|
+
'maxLength',
|
|
95
|
+
'pattern',
|
|
96
|
+
'multipleOf',
|
|
97
|
+
'minimum',
|
|
98
|
+
'maximum',
|
|
99
|
+
'exclusiveMinimum',
|
|
100
|
+
'exclusiveMaximum',
|
|
101
|
+
'minItems',
|
|
102
|
+
'maxItems',
|
|
103
|
+
'uniqueItems',
|
|
104
|
+
'properties',
|
|
105
|
+
'required',
|
|
106
|
+
'additionalProperties',
|
|
107
|
+
'minProperties',
|
|
108
|
+
'maxProperties'
|
|
109
|
+
];
|
|
110
|
+
/** Keywords that `clone` merges with `||`: `false` and absent mean the same. */
|
|
111
|
+
const BOOLEAN_KEYWORDS = [
|
|
112
|
+
'nullable',
|
|
113
|
+
'readOnly',
|
|
114
|
+
'writeOnly',
|
|
115
|
+
'deprecated',
|
|
116
|
+
'exclusiveMinimum',
|
|
117
|
+
'exclusiveMaximum',
|
|
118
|
+
'uniqueItems'
|
|
119
|
+
];
|
|
120
|
+
/**
|
|
121
|
+
* The keywords next to a reference that make `copy` (the target with them
|
|
122
|
+
* applied) differ from `target`. A keyword the target's type does not take,
|
|
123
|
+
* a flag the target already has, and a value equal to the target's change
|
|
124
|
+
* nothing.
|
|
125
|
+
*/
|
|
126
|
+
const toChangedKeywords = (copy, target, siblings) => SIBLINGS_BY_TYPE[target.type].filter(keyword => {
|
|
127
|
+
if (siblings[keyword] === undefined) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const applied = Reflect.get(copy, keyword);
|
|
131
|
+
const original = Reflect.get(target, keyword);
|
|
132
|
+
return BOOLEAN_KEYWORDS.includes(keyword) ? (applied === true) !== (original === true) : !isEqual(applied, original);
|
|
133
|
+
});
|
|
134
|
+
/** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
|
|
135
|
+
export const changesTarget = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).length > 0;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the keywords next to a reference change which values `target`
|
|
138
|
+
* accepts at that site (`minLength` next to a string, `properties` next to an
|
|
139
|
+
* object), not only how it is described (`description`, `deprecated`,
|
|
140
|
+
* `default`, `x-*`). The engine behind `OasRef.hasValueSiblings`.
|
|
141
|
+
*/
|
|
142
|
+
export const changesValues = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).some(keyword => VALUE_KEYWORDS.includes(keyword));
|
|
143
|
+
/**
|
|
144
|
+
* The keywords next to a reference that `clone` leaves out for `target`, by
|
|
145
|
+
* their names in the document: one its type does not have (`minLength` next
|
|
146
|
+
* to an array), a `type` that disagrees with the target's, and an `example`,
|
|
147
|
+
* `default`, `enum` or `format` whose value does not fit. `nullable` says
|
|
148
|
+
* whether the site takes `null` among the `enum` members. The engine behind
|
|
149
|
+
* `OasRef.toSkippedSiblings`.
|
|
150
|
+
*/
|
|
151
|
+
export const toSkippedSiblings = (target, siblings, nullable) => {
|
|
152
|
+
const taken = SIBLINGS_BY_TYPE[target.type];
|
|
153
|
+
const fits = VALUE_CHECKS[target.type];
|
|
154
|
+
const isSkipped = (keyword, value) => {
|
|
155
|
+
if (value === undefined) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (!taken.includes(keyword)) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
switch (keyword) {
|
|
162
|
+
case 'example':
|
|
163
|
+
case 'default':
|
|
164
|
+
return !fits(value);
|
|
165
|
+
case 'enums':
|
|
166
|
+
return !Array.isArray(value) || !value.every(item => fits(item) || (nullable === true && item === null));
|
|
167
|
+
case 'format':
|
|
168
|
+
return !fitsFormat(target.type, value);
|
|
169
|
+
default:
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const type = siblings._type !== undefined && !agrees(siblings._type, target, 0) ? ['type'] : [];
|
|
174
|
+
const others = SIBLING_KEYWORDS.filter(keyword => isSkipped(keyword, siblings[keyword])).map(toDocumentKeyword);
|
|
175
|
+
return [...type, ...others];
|
|
176
|
+
};
|
|
177
|
+
/** How deep {@link agrees} follows union members, so a union that contains itself ends. */
|
|
178
|
+
const MAX_DEPTH = 10;
|
|
179
|
+
/**
|
|
180
|
+
* A `type` next to a reference agrees with the target's when it names it, or
|
|
181
|
+
* `number` for an integer. Next to a union, it agrees when every member,
|
|
182
|
+
* followed through references, has that type (`type: object` next to a
|
|
183
|
+
* `oneOf` of objects): leaving it out then loses nothing.
|
|
184
|
+
*/
|
|
185
|
+
const agrees = (type, target, depth) => {
|
|
186
|
+
if (target.type === 'union') {
|
|
187
|
+
try {
|
|
188
|
+
return depth < MAX_DEPTH &&
|
|
189
|
+
target.members.every(member => agrees(type, member.isRef() ? member.resolve() : member, depth + 1));
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
// A member that is a dangling reference has no known type, so it does not agree.
|
|
193
|
+
if (DanglingRefError.is(error)) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return type === target.type || (type === 'number' && target.type === 'integer');
|
|
200
|
+
};
|
|
201
|
+
/** Whether `format` fits a schema of `type`, as `clone` reads it: any string for a string. */
|
|
202
|
+
const fitsFormat = (type, format) => {
|
|
203
|
+
switch (type) {
|
|
204
|
+
case 'number':
|
|
205
|
+
return isNumberFormat(format);
|
|
206
|
+
case 'integer':
|
|
207
|
+
return isIntegerFormat(format);
|
|
208
|
+
default:
|
|
209
|
+
return isStringValue(format);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
/** The document's name for a keyword: `enum` for `enums`. */
|
|
213
|
+
const toDocumentKeyword = (keyword) => (keyword === 'enums' ? 'enum' : keyword);
|
|
214
|
+
/** The annotations of `target` with those of `siblings` applied: a sibling's value wins, and extension fields merge. */
|
|
215
|
+
export const toSiblingAnnotations = (target, siblings) => ({
|
|
216
|
+
title: siblings?.title ?? target.title,
|
|
217
|
+
description: siblings?.description ?? target.description,
|
|
218
|
+
extensionFields: target.extensionFields === undefined && siblings?.extensionFields === undefined
|
|
219
|
+
? undefined
|
|
220
|
+
: { ...target.extensionFields, ...siblings?.extensionFields }
|
|
221
|
+
});
|
|
222
|
+
/** The value checks the parser makes for `example`, `default` and each `enum` member, by type. */
|
|
223
|
+
export const isStringValue = (value) => typeof value === 'string';
|
|
224
|
+
export const isNumberValue = (value) => typeof value === 'number';
|
|
225
|
+
export const isIntegerValue = (value) => Number.isInteger(value);
|
|
226
|
+
export const isBooleanValue = (value) => typeof value === 'boolean';
|
|
227
|
+
export const isArrayValue = (value) => Array.isArray(value);
|
|
228
|
+
export const isObjectValue = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
229
|
+
const isAnyValue = (_value) => true;
|
|
230
|
+
/** {@link isStringValue} and the others, keyed by the type they check for. A union or unknown takes any value. */
|
|
231
|
+
export const VALUE_CHECKS = {
|
|
232
|
+
string: isStringValue,
|
|
233
|
+
number: isNumberValue,
|
|
234
|
+
integer: isIntegerValue,
|
|
235
|
+
boolean: isBooleanValue,
|
|
236
|
+
array: isArrayValue,
|
|
237
|
+
object: isObjectValue,
|
|
238
|
+
union: isAnyValue,
|
|
239
|
+
unknown: isAnyValue
|
|
240
|
+
};
|
|
241
|
+
/** The formats a number and an integer take. A string takes any format. */
|
|
242
|
+
export const isNumberFormat = (value) => v.is(numberFormat, value);
|
|
243
|
+
export const isIntegerFormat = (value) => v.is(integerFormat, value);
|
|
244
|
+
/** `value` when it passes `check`, else `undefined`: for `example`, `default` and `format`. */
|
|
245
|
+
export const toSiblingValue = (value, check) => check(value) ? value : undefined;
|
|
246
|
+
/**
|
|
247
|
+
* `enums` when every member passes `check`, or is `null` at a nullable site,
|
|
248
|
+
* else `undefined`. The parser reports the members that do not.
|
|
249
|
+
*/
|
|
250
|
+
export const toSiblingEnums = (enums, check, nullable) => enums?.every((item) => check(item) || (nullable === true && item === null)) ? enums : undefined;
|
|
@@ -73,6 +73,10 @@ export declare class OasHttpSecurityScheme {
|
|
|
73
73
|
bearerFormat: string | undefined;
|
|
74
74
|
constructor(fields: HttpSecuritySchemeFields);
|
|
75
75
|
isRef(): this is OasRef<'securityScheme'>;
|
|
76
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
77
|
+
isReadOnly(): boolean;
|
|
78
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
79
|
+
isWriteOnly(): boolean;
|
|
76
80
|
resolve(): OasHttpSecurityScheme;
|
|
77
81
|
resolveOnce(): OasHttpSecurityScheme;
|
|
78
82
|
toJsonSchema(): HttpSecuritySchemeJson;
|
|
@@ -86,6 +90,10 @@ export declare class OasApiKeySecurityScheme {
|
|
|
86
90
|
location: 'query' | 'header' | 'cookie';
|
|
87
91
|
constructor(fields: ApiKeySecuritySchemeFields);
|
|
88
92
|
isRef(): this is OasRef<'securityScheme'>;
|
|
93
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
94
|
+
isReadOnly(): boolean;
|
|
95
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
96
|
+
isWriteOnly(): boolean;
|
|
89
97
|
resolve(): OasApiKeySecurityScheme;
|
|
90
98
|
resolveOnce(): OasApiKeySecurityScheme;
|
|
91
99
|
toJsonSchema(): ApiKeySecuritySchemeJson;
|
|
@@ -136,6 +144,10 @@ export declare class OasOAuth2SecurityScheme {
|
|
|
136
144
|
};
|
|
137
145
|
constructor(fields: OAuth2SecuritySchemeFields);
|
|
138
146
|
isRef(): this is OasRef<'securityScheme'>;
|
|
147
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
148
|
+
isReadOnly(): boolean;
|
|
149
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
150
|
+
isWriteOnly(): boolean;
|
|
139
151
|
resolve(): OasOAuth2SecurityScheme;
|
|
140
152
|
resolveOnce(): OasOAuth2SecurityScheme;
|
|
141
153
|
toJsonSchema(): OAuth2SecuritySchemeJson;
|
|
@@ -148,6 +160,10 @@ export declare class OasOpenIdSecurityScheme {
|
|
|
148
160
|
openIdConnectUrl: string;
|
|
149
161
|
constructor(fields: OpenIdSecuritySchemeFields);
|
|
150
162
|
isRef(): this is OasRef<'securityScheme'>;
|
|
163
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
164
|
+
isReadOnly(): boolean;
|
|
165
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
166
|
+
isWriteOnly(): boolean;
|
|
151
167
|
resolve(): OasOpenIdSecurityScheme;
|
|
152
168
|
resolveOnce(): OasOpenIdSecurityScheme;
|
|
153
169
|
toJsonSchema(): OpenIdSecuritySchemeJson;
|
|
@@ -44,6 +44,14 @@ export class OasHttpSecurityScheme {
|
|
|
44
44
|
isRef() {
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
48
|
+
isReadOnly() {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
52
|
+
isWriteOnly() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
47
55
|
resolve() {
|
|
48
56
|
return this;
|
|
49
57
|
}
|
|
@@ -106,6 +114,14 @@ export class OasApiKeySecurityScheme {
|
|
|
106
114
|
isRef() {
|
|
107
115
|
return false;
|
|
108
116
|
}
|
|
117
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
118
|
+
isReadOnly() {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
122
|
+
isWriteOnly() {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
109
125
|
resolve() {
|
|
110
126
|
return this;
|
|
111
127
|
}
|
|
@@ -167,6 +183,14 @@ export class OasOAuth2SecurityScheme {
|
|
|
167
183
|
isRef() {
|
|
168
184
|
return false;
|
|
169
185
|
}
|
|
186
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
187
|
+
isReadOnly() {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
191
|
+
isWriteOnly() {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
170
194
|
resolve() {
|
|
171
195
|
return this;
|
|
172
196
|
}
|
|
@@ -232,6 +256,14 @@ export class OasOpenIdSecurityScheme {
|
|
|
232
256
|
isRef() {
|
|
233
257
|
return false;
|
|
234
258
|
}
|
|
259
|
+
/** Always `false`: `readOnly` is a schema keyword. */
|
|
260
|
+
isReadOnly() {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
/** Always `false`: `writeOnly` is a schema keyword. */
|
|
264
|
+
isWriteOnly() {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
235
267
|
resolve() {
|
|
236
268
|
return this;
|
|
237
269
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
|
+
import type { OasUnknown } from '../unknown/Unknown.js';
|
|
2
3
|
import type { SchemaPath } from '../../types/SchemaPath.js';
|
|
3
4
|
import type { OasRef } from '../ref/Ref.js';
|
|
4
5
|
import type { OasSchema, ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
@@ -102,8 +103,26 @@ export declare class OasString<Nullable extends boolean | undefined = boolean |
|
|
|
102
103
|
* Whether the string is deprecated.
|
|
103
104
|
*/
|
|
104
105
|
deprecated: boolean | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The schema's `not`, kept as an `OasUnknown` under `client.json`
|
|
108
|
+
* `system.not: unknown`: the document says "not something", and core does
|
|
109
|
+
* not read what. `undefined` otherwise.
|
|
110
|
+
*/
|
|
111
|
+
not: OasUnknown | undefined;
|
|
105
112
|
constructor(fields?: StringFields<Nullable>, context?: ParseContextType);
|
|
106
113
|
isRef(): this is OasRef<'schema'>;
|
|
114
|
+
/** Whether the value is `readOnly`: sent by the API only, never in a request. */
|
|
115
|
+
isReadOnly(): boolean;
|
|
116
|
+
/** Whether the value is `writeOnly`: sent in a request only, never by the API. */
|
|
117
|
+
isWriteOnly(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* A copy of this schema with what `ref` adds at its site applied: its
|
|
120
|
+
* `nullable`, `readOnly`, `writeOnly` and the keywords next to it (`SiblingKeywords`) that
|
|
121
|
+
* this type takes, a sibling's value winning. A value that does not fit
|
|
122
|
+
* this type is left out (the parser reports it). For `OasRef.resolve()`.
|
|
123
|
+
* This schema does not change, and the copy shares its child schemas.
|
|
124
|
+
*/
|
|
125
|
+
clone(ref?: OasRef<'schema'>): OasString;
|
|
107
126
|
traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
|
|
108
127
|
resolve(): OasString<Nullable>;
|
|
109
128
|
resolveOnce(): OasString<Nullable>;
|
package/esm/oas/string/String.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
import { traverseSchema } from '../schemaPath/traverseSchema.js';
|
|
3
|
+
import { toSiblingAnnotations, toSiblingEnums, toSiblingValue, isStringValue } from '../schema/siblings.js';
|
|
3
4
|
import { OasBase } from '../../types/OasBase.js';
|
|
4
5
|
export class OasString extends OasBase {
|
|
5
6
|
constructor(fields = {}, context) {
|
|
@@ -145,6 +146,17 @@ export class OasString extends OasBase {
|
|
|
145
146
|
writable: true,
|
|
146
147
|
value: void 0
|
|
147
148
|
});
|
|
149
|
+
/**
|
|
150
|
+
* The schema's `not`, kept as an `OasUnknown` under `client.json`
|
|
151
|
+
* `system.not: unknown`: the document says "not something", and core does
|
|
152
|
+
* not read what. `undefined` otherwise.
|
|
153
|
+
*/
|
|
154
|
+
Object.defineProperty(this, "not", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: undefined
|
|
159
|
+
});
|
|
148
160
|
this.title = fields.title;
|
|
149
161
|
this.description = fields.description;
|
|
150
162
|
this.format = fields.format;
|
|
@@ -163,6 +175,41 @@ export class OasString extends OasBase {
|
|
|
163
175
|
isRef() {
|
|
164
176
|
return false;
|
|
165
177
|
}
|
|
178
|
+
/** Whether the value is `readOnly`: sent by the API only, never in a request. */
|
|
179
|
+
isReadOnly() {
|
|
180
|
+
return this.readOnly === true;
|
|
181
|
+
}
|
|
182
|
+
/** Whether the value is `writeOnly`: sent in a request only, never by the API. */
|
|
183
|
+
isWriteOnly() {
|
|
184
|
+
return this.writeOnly === true;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A copy of this schema with what `ref` adds at its site applied: its
|
|
188
|
+
* `nullable`, `readOnly`, `writeOnly` and the keywords next to it (`SiblingKeywords`) that
|
|
189
|
+
* this type takes, a sibling's value winning. A value that does not fit
|
|
190
|
+
* this type is left out (the parser reports it). For `OasRef.resolve()`.
|
|
191
|
+
* This schema does not change, and the copy shares its child schemas.
|
|
192
|
+
*/
|
|
193
|
+
clone(ref) {
|
|
194
|
+
const nullable = this.nullable || ref?.nullable || undefined;
|
|
195
|
+
const copy = new OasString({
|
|
196
|
+
...toSiblingAnnotations(this, ref),
|
|
197
|
+
example: toSiblingValue(ref?.example, isStringValue) ?? this.example,
|
|
198
|
+
format: ref?.format ?? this.format,
|
|
199
|
+
enums: toSiblingEnums(ref?.enums, isStringValue, nullable) ?? this.enums,
|
|
200
|
+
nullable,
|
|
201
|
+
maxLength: ref?.maxLength ?? this.maxLength,
|
|
202
|
+
minLength: ref?.minLength ?? this.minLength,
|
|
203
|
+
pattern: ref?.pattern ?? this.pattern,
|
|
204
|
+
default: toSiblingValue(ref?.default, isStringValue) ?? this.default,
|
|
205
|
+
readOnly: this.readOnly || ref?.readOnly || undefined,
|
|
206
|
+
writeOnly: this.writeOnly || ref?.writeOnly || undefined,
|
|
207
|
+
deprecated: ref?.deprecated ?? this.deprecated,
|
|
208
|
+
});
|
|
209
|
+
copy.stackTrail = this.stackTrail;
|
|
210
|
+
copy.not = this.not;
|
|
211
|
+
return copy;
|
|
212
|
+
}
|
|
166
213
|
traverse(path) {
|
|
167
214
|
return traverseSchema(this, path);
|
|
168
215
|
}
|
package/esm/oas/union/Union.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OasUnknown } from '../unknown/Unknown.js';
|
|
1
2
|
import type { SchemaPath } from '../../types/SchemaPath.js';
|
|
2
3
|
import type { OasDiscriminator } from '../discriminator/Discriminator.js';
|
|
3
4
|
import type { OasExternalDocs } from '../externalDocs/ExternalDocs.js';
|
|
@@ -186,10 +187,41 @@ export declare class OasUnion extends OasBase {
|
|
|
186
187
|
* The default value of the union type.
|
|
187
188
|
*/
|
|
188
189
|
default?: unknown;
|
|
190
|
+
/**
|
|
191
|
+
* The schema's `not`, kept as an `OasUnknown` under `client.json`
|
|
192
|
+
* `system.not: unknown`: the document says "not something", and core does
|
|
193
|
+
* not read what. `undefined` otherwise.
|
|
194
|
+
*/
|
|
195
|
+
not: OasUnknown | undefined;
|
|
189
196
|
constructor(fields: UnionFields, context?: ParseContextType);
|
|
190
197
|
isRef(): this is OasRef<'schema'>;
|
|
198
|
+
/** Always `false`: this schema has no `readOnly`. */
|
|
199
|
+
isReadOnly(): boolean;
|
|
200
|
+
/** Always `false`: this schema has no `writeOnly`. */
|
|
201
|
+
isWriteOnly(): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* A copy of this schema with what `ref` adds at its site applied: its
|
|
204
|
+
* `nullable` and the keywords next to it (`SiblingKeywords`) that
|
|
205
|
+
* this type takes, a sibling's value winning. A value that does not fit
|
|
206
|
+
* this type is left out (the parser reports it). For `OasRef.resolve()`.
|
|
207
|
+
* This schema does not change, and the copy shares its child schemas.
|
|
208
|
+
*/
|
|
209
|
+
clone(ref?: OasRef<'schema'>): OasUnion;
|
|
191
210
|
traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
|
|
192
211
|
resolve(): OasUnion;
|
|
193
212
|
resolveOnce(): OasUnion;
|
|
213
|
+
/**
|
|
214
|
+
* Whether the discriminator alone picks the member of a value: the union
|
|
215
|
+
* names a discriminator, and each member, followed through references, is
|
|
216
|
+
* an object that is not nullable, that requires the discriminator's
|
|
217
|
+
* property, and that allows only string literals for it. No value may
|
|
218
|
+
* belong to two members. A member that is a union, or anything other than
|
|
219
|
+
* an object, makes it `false`, as does a reference on the way that names
|
|
220
|
+
* nothing in the document (kept under `system.danglingRefs: keep`).
|
|
221
|
+
*
|
|
222
|
+
* It reads the schemas only. A generator may refuse more: one that leaves
|
|
223
|
+
* out `readOnly` properties cannot discriminate on one.
|
|
224
|
+
*/
|
|
225
|
+
isDiscriminable(): boolean;
|
|
194
226
|
toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.NonArraySchemaObject;
|
|
195
227
|
}
|