@skmtc/core 0.38.0 → 0.40.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 +5 -4
- package/esm/context/GenerateContext.js +110 -37
- package/esm/context/ParseContext.d.ts +9 -1
- package/esm/context/ParseContext.js +12 -1
- package/esm/context/generateTypes.d.ts +19 -4
- package/esm/context/generateTypes.js +2 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- 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/mod.d.ts +1 -0
- package/esm/mod.js +1 -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 +5 -1
- package/esm/oas/operation/Operation.js +17 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +16 -0
- package/esm/oas/operation/toEffectiveParameters.js +13 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/Ref.d.ts +147 -25
- package/esm/oas/ref/Ref.js +387 -25
- 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 +240 -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 +31 -0
- package/esm/oas/union/Union.js +100 -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 +6 -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/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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +2 -2
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +34 -0
- package/esm/types/Settings.js +8 -0
- package/package.json +1 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +5 -4
- package/script/context/GenerateContext.js +110 -37
- package/script/context/ParseContext.d.ts +9 -1
- package/script/context/ParseContext.js +12 -1
- package/script/context/generateTypes.d.ts +19 -4
- package/script/context/generateTypes.js +2 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- 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/mod.d.ts +1 -0
- package/script/mod.js +1 -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 +5 -1
- package/script/oas/operation/Operation.js +17 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +16 -0
- package/script/oas/operation/toEffectiveParameters.js +17 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/Ref.d.ts +147 -25
- package/script/oas/ref/Ref.js +387 -25
- 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 +295 -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 +31 -0
- package/script/oas/union/Union.js +100 -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 +6 -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/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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +2 -2
- 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/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +2 -2
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +34 -0
- package/script/types/Settings.js +9 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeIntegerConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeIntegerConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,10 +2,10 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { mergeBounds } from './merge-bounds.js';
|
|
5
|
-
export function mergeIntegerConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeIntegerConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
// First merge enum values if present
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.number() });
|
|
9
9
|
// Then merge other constraints
|
|
10
10
|
result.type = 'integer';
|
|
11
11
|
mergeBounds(result, first, second);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeIntersectionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
5
|
normalize: NormalizeFn;
|
|
6
|
+
system: MergeSystem;
|
|
6
7
|
throwOnConflict?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const mergeIntersection: ({ schema, getRef, normalize }: MergeIntersectionArgs) => SchemaOrReference;
|
|
9
|
+
export declare const mergeIntersection: ({ schema, getRef, normalize, system }: MergeIntersectionArgs) => SchemaOrReference;
|
|
9
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decomposeIntersection } from './decompose-intersection.js';
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
|
-
export const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
3
|
+
export const mergeIntersection = ({ schema, getRef, normalize, system }) => {
|
|
4
4
|
const decomposed = decomposeIntersection({ schema });
|
|
5
5
|
if (decomposed.length === 1) {
|
|
6
6
|
return decomposed[0];
|
|
@@ -9,7 +9,7 @@ export const mergeIntersection = ({ schema, getRef, normalize }) => {
|
|
|
9
9
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
10
10
|
});
|
|
11
11
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
12
|
-
const merged = mergeSchemasOrRefs(acc, decomposed, getRef, normalize);
|
|
12
|
+
const merged = mergeSchemasOrRefs({ first: acc, second: decomposed, getRef, normalize, system });
|
|
13
13
|
return merged;
|
|
14
14
|
}, {});
|
|
15
15
|
return result;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeNumberConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeNumberConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,10 +2,10 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { mergeBounds } from './merge-bounds.js';
|
|
5
|
-
export function mergeNumberConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeNumberConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
// First merge enum values if present
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.number());
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.number() });
|
|
9
9
|
// Then merge other constraints
|
|
10
10
|
result.type = 'number';
|
|
11
11
|
mergeBounds(result, first, second);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
1
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type { GetRefFn, NormalizeFn } from './types.js';
|
|
3
3
|
type SchemaObject = OpenAPIV3.SchemaObject;
|
|
4
|
-
export declare const mergeObjectConstraints: (first
|
|
4
|
+
export declare const mergeObjectConstraints: ({ first, second, getRef, normalize, system }: MergeArgs<SchemaObject>) => SchemaObject;
|
|
5
5
|
export {};
|
|
@@ -2,14 +2,14 @@ import { mergeSchemasOrRefs } from './merge.js';
|
|
|
2
2
|
import { genericMerge } from './generic-merge.js';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
5
|
-
export const mergeObjectConstraints = (first, second, getRef, normalize) => {
|
|
5
|
+
export const mergeObjectConstraints = ({ first, second, getRef, normalize, system }) => {
|
|
6
6
|
// Check for type conflicts
|
|
7
7
|
checkTypeConflicts(first, second);
|
|
8
|
-
const result = genericMerge(first, second, getRef, normalize, v.record(v.string(), v.any()));
|
|
8
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.record(v.string(), v.any()) });
|
|
9
9
|
if (typeof second.additionalProperties === 'object' &&
|
|
10
10
|
typeof first.additionalProperties === 'object') {
|
|
11
11
|
// If both have additionalProperties as schemas, merge them
|
|
12
|
-
result.additionalProperties = mergeSchemasOrRefs(first.additionalProperties, second.additionalProperties, getRef, normalize);
|
|
12
|
+
result.additionalProperties = mergeSchemasOrRefs({ first: first.additionalProperties, second: second.additionalProperties, getRef, normalize, system });
|
|
13
13
|
}
|
|
14
14
|
else if (second.additionalProperties !== undefined) {
|
|
15
15
|
result.additionalProperties = second.additionalProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject,
|
|
2
|
-
export declare const mergeProperties: (first
|
|
1
|
+
import type { SchemaObject, MergeArgs } from './types.js';
|
|
2
|
+
export declare const mergeProperties: ({ first, second, getRef, normalize, system }: MergeArgs<SchemaObject>) => SchemaObject | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
2
|
-
export const mergeProperties = (first, second, getRef, normalize) => {
|
|
2
|
+
export const mergeProperties = ({ first, second, getRef, normalize, system }) => {
|
|
3
3
|
if (containsProperties(first, second)) {
|
|
4
4
|
const properties = { ...first.properties };
|
|
5
5
|
if (!properties) {
|
|
@@ -9,7 +9,7 @@ export const mergeProperties = (first, second, getRef, normalize) => {
|
|
|
9
9
|
}
|
|
10
10
|
for (const key in second.properties) {
|
|
11
11
|
if (key in properties) {
|
|
12
|
-
properties[key] = mergeSchemasOrRefs(properties[key], second.properties[key], getRef, normalize);
|
|
12
|
+
properties[key] = mergeSchemasOrRefs({ first: properties[key], second: second.properties[key], getRef, normalize, system });
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
properties[key] = second.properties[key];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeStringConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeStringConstraints({ first, second, getRef, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -2,13 +2,13 @@ import { genericMerge } from './generic-merge.js';
|
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
4
|
import { checkAtLeastOneTypeMatch } from './check-at-least-one-type-match.js';
|
|
5
|
-
export function mergeStringConstraints(first, second, getRef, normalize) {
|
|
5
|
+
export function mergeStringConstraints({ first, second, getRef, normalize, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
if (!checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
8
|
-
return genericMerge(first, second, getRef, normalize);
|
|
8
|
+
return genericMerge({ first, second, getRef, normalize, system });
|
|
9
9
|
}
|
|
10
10
|
// First merge enum values if present
|
|
11
|
-
const result = genericMerge(first, second, getRef, normalize, v.string());
|
|
11
|
+
const result = genericMerge({ first, second, getRef, normalize, system, typeCheck: v.string() });
|
|
12
12
|
// Then merge other constraints
|
|
13
13
|
result.type = 'string';
|
|
14
14
|
// Merge minLength
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, NormalizeFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeUnionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
5
|
normalize: NormalizeFn;
|
|
6
|
+
system: MergeSystem;
|
|
6
7
|
groupType: 'oneOf' | 'anyOf';
|
|
7
8
|
};
|
|
8
|
-
export declare const mergeUnion: ({ schema, getRef, normalize, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
9
|
+
export declare const mergeUnion: ({ schema, getRef, normalize, system, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
9
10
|
type MergeCrossProductArgs = {
|
|
10
11
|
first: SchemaObject;
|
|
11
12
|
second: SchemaObject;
|
|
12
13
|
getRef: GetRefFn;
|
|
13
14
|
normalize: NormalizeFn;
|
|
15
|
+
system: MergeSystem;
|
|
14
16
|
groupType: 'oneOf' | 'anyOf';
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
20
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
21
|
+
*/
|
|
22
|
+
export declare const toOwnSystem: (system: MergeSystem) => MergeSystem;
|
|
23
|
+
export declare const mergeCrossProduct: ({ first, second, getRef, normalize, system, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
17
24
|
/**
|
|
18
25
|
* A `oneOf`/`anyOf` whose every member is null-only (for example
|
|
19
26
|
* `oneOf: [{ type: 'null' }]`) reads as nullable with no other type, not
|
|
@@ -2,7 +2,7 @@ import { decomposeUnion, isUnionLevelKey } from './decompose-union.js';
|
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
3
|
import { crossProduct } from './cross-product.js';
|
|
4
4
|
import { isRef } from '../../../helpers/refFns.js';
|
|
5
|
-
export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
5
|
+
export const mergeUnion = ({ schema, getRef, normalize, system, groupType }) => {
|
|
6
6
|
const { beforeExcluded, decomposed, afterExcluded } = decomposeUnion({ schema, groupType });
|
|
7
7
|
// if (decomposed.length === 1) {
|
|
8
8
|
// console.log('DECOMPOSED', JSON.stringify(decomposed[0], null, 2))
|
|
@@ -23,6 +23,7 @@ export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
|
23
23
|
second: decomposed,
|
|
24
24
|
getRef,
|
|
25
25
|
normalize,
|
|
26
|
+
system,
|
|
26
27
|
groupType
|
|
27
28
|
});
|
|
28
29
|
return merged;
|
|
@@ -34,7 +35,51 @@ export const mergeUnion = ({ schema, getRef, normalize, groupType }) => {
|
|
|
34
35
|
};
|
|
35
36
|
return output;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
40
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
41
|
+
*/
|
|
42
|
+
export const toOwnSystem = (system) => ({
|
|
43
|
+
...system,
|
|
44
|
+
allOf: system.setting ?? system.allOf,
|
|
45
|
+
setting: undefined
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The merge of each pair of the cross product whose members do not
|
|
49
|
+
* contradict. Such a pair is no value of the union, so it is left out, as
|
|
50
|
+
* under `strict`. Only when every pair contradicts does `latestWins` merge
|
|
51
|
+
* them again, the later member winning, without duplicates: Cloudflare's
|
|
52
|
+
* collections say `result` is an object or a string, then an array.
|
|
53
|
+
*
|
|
54
|
+
* The first pass is strict between the two members of a pair only. A
|
|
55
|
+
* member's own `allOf` merges under the `client.json` setting
|
|
56
|
+
* ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
|
|
57
|
+
* cross product with no pair that merges fails its pair: the outer pass then
|
|
58
|
+
* leaves the pair out, or lets the later member win.
|
|
59
|
+
*/
|
|
60
|
+
const mergePairs = ({ pairs, merge, system }) => {
|
|
61
|
+
const mergeEach = (pairSystem) => pairs.flatMap(pair => {
|
|
62
|
+
try {
|
|
63
|
+
return [merge(pair, pairSystem)];
|
|
64
|
+
}
|
|
65
|
+
catch (_error) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const strict = mergeEach({ ...system, allOf: 'strict', setting: system.setting ?? system.allOf });
|
|
70
|
+
if (strict.length > 0) {
|
|
71
|
+
return strict;
|
|
72
|
+
}
|
|
73
|
+
if (system.allOf === 'strict' && system.setting === 'latestWins') {
|
|
74
|
+
throw new Error('No pair of the cross product merges');
|
|
75
|
+
}
|
|
76
|
+
if (system.allOf === 'strict') {
|
|
77
|
+
return strict;
|
|
78
|
+
}
|
|
79
|
+
const latest = mergeEach(system).map(item => ({ item, key: JSON.stringify(item) }));
|
|
80
|
+
return latest.filter(({ key }, index) => latest.findIndex(other => other.key === key) === index).map(({ item }) => item);
|
|
81
|
+
};
|
|
82
|
+
export const mergeCrossProduct = ({ first, second, getRef, normalize, system, groupType }) => {
|
|
38
83
|
const firstMembers = Array.isArray(first[groupType]) ? first[groupType] : [first];
|
|
39
84
|
const secondMembers = Array.isArray(second[groupType]) ? second[groupType] : [second];
|
|
40
85
|
// A member that normalizes to `{ nullable: true }`, with at most union-level
|
|
@@ -46,17 +91,11 @@ export const mergeCrossProduct = ({ first, second, getRef, normalize, groupType
|
|
|
46
91
|
isNullableGroup(second, groupType) ||
|
|
47
92
|
firstGroup.length !== firstMembers.length ||
|
|
48
93
|
secondGroup.length !== secondMembers.length;
|
|
49
|
-
const mergedGroup =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
catch (_error) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
.filter(item => item !== undefined);
|
|
94
|
+
const mergedGroup = mergePairs({
|
|
95
|
+
pairs: crossProduct(withGroupSiblings({ schema: first, members: firstGroup, getRef, normalize, system, groupType }), withGroupSiblings({ schema: second, members: secondGroup, getRef, normalize, system, groupType })),
|
|
96
|
+
merge: ([firstItem, secondItem], pairSystem) => mergeSchemasOrRefs({ first: firstItem, second: secondItem, getRef, normalize, system: pairSystem }),
|
|
97
|
+
system
|
|
98
|
+
});
|
|
60
99
|
// A nested group is spread into this one below; its `nullable` carries over.
|
|
61
100
|
const nestedNullable = mergedGroup.some(item => !isRef(item) && Array.isArray(item[groupType]) && item.nullable === true);
|
|
62
101
|
return {
|
|
@@ -78,7 +117,7 @@ export const mergeCrossProduct = ({ first, second, getRef, normalize, groupType
|
|
|
78
117
|
* siblings is dropped, as in the cross product. A schema with no group is
|
|
79
118
|
* its own only member and is returned unchanged.
|
|
80
119
|
*/
|
|
81
|
-
const withGroupSiblings = ({ schema, members, getRef, normalize, groupType }) => {
|
|
120
|
+
const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupType }) => {
|
|
82
121
|
if (!Array.isArray(schema[groupType])) {
|
|
83
122
|
return members;
|
|
84
123
|
}
|
|
@@ -94,7 +133,7 @@ const withGroupSiblings = ({ schema, members, getRef, normalize, groupType }) =>
|
|
|
94
133
|
return member;
|
|
95
134
|
}
|
|
96
135
|
try {
|
|
97
|
-
return mergeSchemasOrRefs(siblingSchema, member, getRef, normalize);
|
|
136
|
+
return mergeSchemasOrRefs({ first: siblingSchema, second: member, getRef, normalize, system });
|
|
98
137
|
}
|
|
99
138
|
catch (_error) {
|
|
100
139
|
return undefined;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
2
|
+
import type { SchemaOrReference } from './types.js';
|
|
3
|
+
export declare const mergeSchemasOrRefs: ({ first: inputFirst, second: inputSecond, getRef, normalize, system }: MergeArgs<SchemaOrReference>) => SchemaOrReference;
|
|
@@ -14,10 +14,11 @@ import { mergeBooleanConstraints } from './merge-boolean-constraints.js';
|
|
|
14
14
|
import { genericMerge } from './generic-merge.js';
|
|
15
15
|
import { checkAtLeastOneTypeMatch } from './check-at-least-one-type-match.js';
|
|
16
16
|
import { mergeIntersection } from './merge-intersection.js';
|
|
17
|
-
import { collapseNullOnlyUnion, mergeCrossProduct } from './merge-union.js';
|
|
17
|
+
import { collapseNullOnlyUnion, mergeCrossProduct, toOwnSystem } from './merge-union.js';
|
|
18
18
|
import { isEmpty } from '../../../helpers/isEmpty.js';
|
|
19
19
|
import { isNullOnly, mergeNullOnly } from './nullable-merge.js';
|
|
20
|
-
|
|
20
|
+
import { withoutUnknownAnyOf } from '../../anyOfSystem.js';
|
|
21
|
+
export const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, normalize, system }) => {
|
|
21
22
|
const first = isRef(inputFirst)
|
|
22
23
|
? inputFirst
|
|
23
24
|
: collapseNullOnlyUnion(normalize(inputFirst), normalize);
|
|
@@ -25,7 +26,7 @@ export const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) =
|
|
|
25
26
|
? inputSecond
|
|
26
27
|
: collapseNullOnlyUnion(normalize(inputSecond), normalize);
|
|
27
28
|
if (containsRef(first, second)) {
|
|
28
|
-
return mergeWithRef(first, second, getRef, normalize);
|
|
29
|
+
return mergeWithRef({ first, second, getRef, normalize, system });
|
|
29
30
|
}
|
|
30
31
|
if (isRef(first)) {
|
|
31
32
|
throw new Error('Ref in first');
|
|
@@ -33,20 +34,32 @@ export const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) =
|
|
|
33
34
|
if (isRef(second)) {
|
|
34
35
|
throw new Error('Ref in second');
|
|
35
36
|
}
|
|
37
|
+
// Under `system.anyOf: unknown` an `anyOf` of two or more members is any
|
|
38
|
+
// value, so it adds nothing to the merge: its members are left out, and the
|
|
39
|
+
// keywords next to it merge as usual.
|
|
40
|
+
const firstKeywords = withoutUnknownAnyOf({ schema: first, setting: system.anyOf, getRef });
|
|
41
|
+
const secondKeywords = withoutUnknownAnyOf({ schema: second, setting: system.anyOf, getRef });
|
|
42
|
+
if (firstKeywords !== first || secondKeywords !== second) {
|
|
43
|
+
system.unknown?.add('anyOf');
|
|
44
|
+
return mergeSchemasOrRefs({ first: firstKeywords, second: secondKeywords, getRef, normalize, system });
|
|
45
|
+
}
|
|
36
46
|
if (containsAllOf(first) || containsAllOf(second)) {
|
|
47
|
+
// Each member's own `allOf` merges under the `client.json` setting, also in
|
|
48
|
+
// the strict first pass over a cross product's pairs.
|
|
49
|
+
const ownSystem = toOwnSystem(system);
|
|
37
50
|
const mergedFirst = containsAllOf(first)
|
|
38
|
-
? mergeIntersection({ schema: first, getRef, normalize })
|
|
51
|
+
? mergeIntersection({ schema: first, getRef, normalize, system: ownSystem })
|
|
39
52
|
: first;
|
|
40
53
|
const mergedSecond = containsAllOf(second)
|
|
41
|
-
? mergeIntersection({ schema: second, getRef, normalize })
|
|
54
|
+
? mergeIntersection({ schema: second, getRef, normalize, system: ownSystem })
|
|
42
55
|
: second;
|
|
43
|
-
return mergeSchemasOrRefs(mergedFirst, mergedSecond, getRef, normalize);
|
|
56
|
+
return mergeSchemasOrRefs({ first: mergedFirst, second: mergedSecond, getRef, normalize, system });
|
|
44
57
|
}
|
|
45
58
|
if (containsOneOf(first, second)) {
|
|
46
|
-
return mergeCrossProduct({ first, second, getRef, normalize, groupType: 'oneOf' });
|
|
59
|
+
return mergeCrossProduct({ first, second, getRef, normalize, system, groupType: 'oneOf' });
|
|
47
60
|
}
|
|
48
61
|
if (containsAnyOf(first, second)) {
|
|
49
|
-
return mergeCrossProduct({ first, second, getRef, normalize, groupType: 'anyOf' });
|
|
62
|
+
return mergeCrossProduct({ first, second, getRef, normalize, system, groupType: 'anyOf' });
|
|
50
63
|
}
|
|
51
64
|
if (isNullOnly(first)) {
|
|
52
65
|
return mergeNullOnly(second);
|
|
@@ -54,7 +67,7 @@ export const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) =
|
|
|
54
67
|
if (isNullOnly(second)) {
|
|
55
68
|
return mergeNullOnly(first);
|
|
56
69
|
}
|
|
57
|
-
return mergeSchemas(first, second, getRef, normalize);
|
|
70
|
+
return mergeSchemas({ first, second, getRef, normalize, system });
|
|
58
71
|
};
|
|
59
72
|
const containsAllOf = (schema) => {
|
|
60
73
|
if (schema.allOf) {
|
|
@@ -98,48 +111,91 @@ const containsOneOf = (first, second) => {
|
|
|
98
111
|
const containsRef = (first, second) => {
|
|
99
112
|
return isRef(first) || isRef(second);
|
|
100
113
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
/** Whether one member says `number` and the other `integer`. */
|
|
115
|
+
const isNumberAndInteger = (first, second) => (first.type === 'number' && second.type === 'integer') || (first.type === 'integer' && second.type === 'number');
|
|
116
|
+
const mergeSchemas = ({ first, second, getRef, normalize, system }) => {
|
|
117
|
+
// Every integer is a number, so a `number` merged with an `integer` is an
|
|
118
|
+
// `integer` with the constraints of both. Nothing contradicts.
|
|
119
|
+
if (isNumberAndInteger(first, second)) {
|
|
120
|
+
return mergeSchemas({
|
|
121
|
+
first: { ...first, type: 'integer' },
|
|
122
|
+
second: { ...second, type: 'integer' },
|
|
123
|
+
getRef,
|
|
124
|
+
normalize,
|
|
125
|
+
system
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (system.allOf === 'latestWins') {
|
|
129
|
+
// The later member wins a contradiction: a type it disagrees with makes
|
|
130
|
+
// it the whole schema, and any other keyword it disagrees with is left
|
|
131
|
+
// out of the earlier member before they merge.
|
|
132
|
+
if (first.type && second.type && first.type !== second.type) {
|
|
133
|
+
system.replaced.add('type');
|
|
134
|
+
return second;
|
|
135
|
+
}
|
|
136
|
+
const earlier = withoutContradictions({ first, second, normalize, replaced: system.replaced });
|
|
137
|
+
return mergeChecked({ first: earlier, second, getRef, normalize, system });
|
|
107
138
|
}
|
|
139
|
+
return mergeChecked({ first, second, getRef, normalize, system });
|
|
140
|
+
};
|
|
141
|
+
/** `first` without the keywords that contradict `second`, each named in `replaced`. */
|
|
142
|
+
const withoutContradictions = ({ first, second, normalize, replaced }) => {
|
|
143
|
+
const contradictions = [
|
|
144
|
+
{ check: checkReadOnlyWriteOnlyConflicts, keywords: ['readOnly', 'writeOnly'] },
|
|
145
|
+
{ check: checkFormatConflicts, keywords: ['format'] },
|
|
146
|
+
{ check: checkEnumConflicts, keywords: ['enum'] },
|
|
147
|
+
{ check: checkNumberConstraintsConflicts, keywords: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'] },
|
|
148
|
+
{ check: (a, b) => checkArrayItemTypeConflicts(a, b, normalize), keywords: ['items'] }
|
|
149
|
+
];
|
|
150
|
+
return contradictions.reduce((earlier, { check, keywords }) => {
|
|
151
|
+
try {
|
|
152
|
+
check(earlier, second);
|
|
153
|
+
return earlier;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
const entries = Object.entries(earlier);
|
|
157
|
+
entries.filter(([key, value]) => keywords.includes(key) && value !== undefined).forEach(([key]) => replaced.add(key));
|
|
158
|
+
return Object.fromEntries(entries.filter(([key]) => !keywords.includes(key)));
|
|
159
|
+
}
|
|
160
|
+
}, first);
|
|
161
|
+
};
|
|
162
|
+
const mergeChecked = ({ first, second, getRef, normalize, system }) => {
|
|
163
|
+
checkTypeConflicts(first, second);
|
|
108
164
|
checkReadOnlyWriteOnlyConflicts(first, second);
|
|
109
165
|
checkFormatConflicts(first, second);
|
|
110
166
|
checkEnumConflicts(first, second);
|
|
111
167
|
checkNumberConstraintsConflicts(first, second);
|
|
112
168
|
checkArrayItemTypeConflicts(first, second, normalize);
|
|
113
|
-
if (first.not || second.not) {
|
|
169
|
+
if ((first.not || second.not) && system.not !== 'unknown') {
|
|
114
170
|
throw new Error('Merging schemas with "not" keyword is not supported');
|
|
115
171
|
}
|
|
116
|
-
return typedMerge(first, second, getRef, normalize);
|
|
172
|
+
return typedMerge({ first, second, getRef, normalize, system });
|
|
117
173
|
};
|
|
118
|
-
const typedMerge = (first, second, getRef, normalize) => {
|
|
174
|
+
const typedMerge = ({ first, second, getRef, normalize, system }) => {
|
|
119
175
|
if (!first.type && !second.type) {
|
|
120
|
-
return genericMerge(first, second, getRef, normalize);
|
|
176
|
+
return genericMerge({ first, second, getRef, normalize, system });
|
|
121
177
|
}
|
|
122
178
|
if (checkAtLeastOneTypeMatch(first, second, 'object')) {
|
|
123
|
-
return mergeObjectConstraints(first, second, getRef, normalize);
|
|
179
|
+
return mergeObjectConstraints({ first, second, getRef, normalize, system });
|
|
124
180
|
}
|
|
125
181
|
if (checkAtLeastOneTypeMatch(first, second, 'array')) {
|
|
126
|
-
return mergeArrayConstraints(first, second, getRef, normalize);
|
|
182
|
+
return mergeArrayConstraints({ first, second, getRef, normalize, system });
|
|
127
183
|
}
|
|
128
184
|
if (checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
129
|
-
return mergeStringConstraints(first, second, getRef, normalize);
|
|
185
|
+
return mergeStringConstraints({ first, second, getRef, normalize, system });
|
|
130
186
|
}
|
|
131
187
|
if (checkAtLeastOneTypeMatch(first, second, 'number')) {
|
|
132
|
-
return mergeNumberConstraints(first, second, getRef, normalize);
|
|
188
|
+
return mergeNumberConstraints({ first, second, getRef, normalize, system });
|
|
133
189
|
}
|
|
134
190
|
if (checkAtLeastOneTypeMatch(first, second, 'integer')) {
|
|
135
|
-
return mergeIntegerConstraints(first, second, getRef, normalize);
|
|
191
|
+
return mergeIntegerConstraints({ first, second, getRef, normalize, system });
|
|
136
192
|
}
|
|
137
193
|
if (checkAtLeastOneTypeMatch(first, second, 'boolean')) {
|
|
138
|
-
return mergeBooleanConstraints(first, second, getRef, normalize);
|
|
194
|
+
return mergeBooleanConstraints({ first, second, getRef, normalize, system });
|
|
139
195
|
}
|
|
140
196
|
throw new Error(`Cannot merge schemas with type "${first.type}" with type "${second.type}"`);
|
|
141
197
|
};
|
|
142
|
-
const mergeWithRef = (first, second, getRef, normalize) => {
|
|
198
|
+
const mergeWithRef = ({ first, second, getRef, normalize, system }) => {
|
|
143
199
|
const readRef = (ref) => normalize(getRef(ref));
|
|
144
200
|
if (isRef(first) && isRef(second)) {
|
|
145
201
|
if (first.$ref === second.$ref) {
|
|
@@ -149,15 +205,18 @@ const mergeWithRef = (first, second, getRef, normalize) => {
|
|
|
149
205
|
};
|
|
150
206
|
}
|
|
151
207
|
else {
|
|
152
|
-
return
|
|
208
|
+
return mergeSchemasOrRefs({ first: readRef(first), second: readRef(second), getRef, normalize, system });
|
|
153
209
|
}
|
|
154
210
|
}
|
|
211
|
+
// A target followed through its reference merges as any schema does: a
|
|
212
|
+
// `oneOf` or `anyOf` in either one is crossed with the other, not kept
|
|
213
|
+
// beside the merged properties.
|
|
155
214
|
if (isRef(first) && !isRef(second)) {
|
|
156
|
-
const merged = isEmpty(second) ? first :
|
|
215
|
+
const merged = isEmpty(second) ? first : mergeSchemasOrRefs({ first: readRef(first), second, getRef, normalize, system });
|
|
157
216
|
return merged;
|
|
158
217
|
}
|
|
159
218
|
if (!isRef(first) && isRef(second)) {
|
|
160
|
-
const merged = isEmpty(first) ? second :
|
|
219
|
+
const merged = isEmpty(first) ? second : mergeSchemasOrRefs({ first, second: readRef(second), getRef, normalize, system });
|
|
161
220
|
return merged;
|
|
162
221
|
}
|
|
163
222
|
throw new Error('Invalid input');
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
/**
|
|
3
|
+
* `schema`, nullable: a copy, as `schema` may be a component that other
|
|
4
|
+
* references share (a target followed through its reference).
|
|
5
|
+
*/
|
|
2
6
|
export declare const mergeNullOnly: (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|
|
3
7
|
export declare const isNullOnly: (schema: OpenAPIV3.SchemaObject) => boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { isEmpty } from '../../../helpers/isEmpty.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
2
|
+
/**
|
|
3
|
+
* `schema`, nullable: a copy, as `schema` may be a component that other
|
|
4
|
+
* references share (a target followed through its reference).
|
|
5
|
+
*/
|
|
6
|
+
export const mergeNullOnly = (schema) => ({
|
|
7
|
+
...schema,
|
|
8
|
+
...(schema.enum && !schema.enum.includes(null) ? { enum: [...schema.enum, null] } : {}),
|
|
9
|
+
nullable: true
|
|
10
|
+
});
|
|
9
11
|
export const isNullOnly = (schema) => {
|
|
10
12
|
const { type: _type, nullable, enum: enumValues, ...rest } = schema;
|
|
11
13
|
return (Boolean(nullable) && enumValues?.length === 1 && enumValues[0] === null && isEmpty(rest ?? {}));
|
|
@@ -7,6 +7,28 @@ export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObjec
|
|
|
7
7
|
* it, so the merge holds no dialect rules of its own. Must be idempotent.
|
|
8
8
|
*/
|
|
9
9
|
export type NormalizeFn = (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|
|
10
|
+
/**
|
|
11
|
+
* The `system` settings as the merge reads them (`client.json#settings.system`),
|
|
12
|
+
* and the keywords a later `allOf` member replaced under `latestWins`, so
|
|
13
|
+
* the parser can name them in one warning for the schema.
|
|
14
|
+
*/
|
|
15
|
+
export type MergeSystem = {
|
|
16
|
+
/** `strict`: a contradiction between members fails the merge. `latestWins`: the later member's keyword wins. */
|
|
17
|
+
allOf: 'strict' | 'latestWins';
|
|
18
|
+
/** `unknown`: a member with `not` merges, its `not` carried as written. Left out: `strict`, which refuses it. */
|
|
19
|
+
not?: 'strict' | 'unknown';
|
|
20
|
+
/**
|
|
21
|
+
* `client.json` `system.allOf`, kept while the first pass over a cross
|
|
22
|
+
* product's pairs sets `allOf` to `strict`. A member's own `allOf` merges
|
|
23
|
+
* under this setting in every pass. Left out: `allOf` is the setting.
|
|
24
|
+
*/
|
|
25
|
+
setting?: 'strict' | 'latestWins';
|
|
26
|
+
replaced: Set<string>;
|
|
27
|
+
/** `unknown`: an `anyOf` of two or more members is any value, so it adds nothing to the merge. Left out: `union`. */
|
|
28
|
+
anyOf?: 'union' | 'unknown';
|
|
29
|
+
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
30
|
+
unknown?: Set<string>;
|
|
31
|
+
};
|
|
10
32
|
export type OneOfObject = {
|
|
11
33
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
12
34
|
} & OpenAPIV3.SchemaObject;
|
|
@@ -16,5 +38,20 @@ export type AnyOfObject = {
|
|
|
16
38
|
export type SchemaObject = OpenAPIV3.SchemaObject;
|
|
17
39
|
export type ReferenceObject = OpenAPIV3.ReferenceObject;
|
|
18
40
|
export type SchemaOrReference = SchemaObject | ReferenceObject;
|
|
41
|
+
/**
|
|
42
|
+
* Two schemas to merge, how to follow a reference and normalize a member, and
|
|
43
|
+
* the `system` settings: what each merge step takes.
|
|
44
|
+
*/
|
|
45
|
+
export type MergeArgs<Schema = SchemaOrReference> = {
|
|
46
|
+
first: Schema;
|
|
47
|
+
second: Schema;
|
|
48
|
+
getRef: GetRefFn;
|
|
49
|
+
normalize: NormalizeFn;
|
|
50
|
+
system: MergeSystem;
|
|
51
|
+
};
|
|
52
|
+
/** {@link MergeArgs}, and the valibot schema `default`, `enum` and `example` values must pass. */
|
|
53
|
+
export type GenericMergeArgs<T> = MergeArgs<SchemaObject> & {
|
|
54
|
+
typeCheck?: v.GenericSchema<T>;
|
|
55
|
+
};
|
|
19
56
|
export type ArraySchemaObject = OpenAPIV3.ArraySchemaObject;
|
|
20
57
|
export declare const IntegerSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, "The number must be an integer.">]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { SiblingKeywords } from '../../../oas/schema/siblings.js';
|
|
2
3
|
import type { OasRefData } from '../../../oas/ref/ref-types.js';
|
|
3
4
|
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
4
5
|
import { OasRef } from '../../../oas/ref/Ref.js';
|
|
@@ -14,6 +15,11 @@ type ToRefV31Args<T extends OasRefData['refType']> = {
|
|
|
14
15
|
* reference; omitted everywhere else (a plain `$ref` is non-nullable).
|
|
15
16
|
*/
|
|
16
17
|
nullable?: boolean;
|
|
18
|
+
/** Use-site `readOnly` and `writeOnly` (see `RefFields.readOnly`): from a one-member `allOf`. */
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
writeOnly?: boolean;
|
|
21
|
+
/** The other keywords next to the reference in a one-member `allOf`, for `RefFields` (see `SiblingKeywords`). */
|
|
22
|
+
siblings?: SiblingKeywords;
|
|
17
23
|
};
|
|
18
|
-
export declare const toRefV31: <T extends OasRefData["refType"]>({ ref, refType, stackTrail, context, nullable }: ToRefV31Args<T>) => OasRef<T>;
|
|
24
|
+
export declare const toRefV31: <T extends OasRefData["refType"]>({ ref, refType, stackTrail, context, nullable, readOnly, writeOnly, siblings }: ToRefV31Args<T>) => OasRef<T>;
|
|
19
25
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { OasRef } from '../../../oas/ref/Ref.js';
|
|
2
2
|
import { isEmpty } from '../../../helpers/isEmpty.js';
|
|
3
|
-
export const toRefV31 = ({ ref, refType, stackTrail, context, nullable }) => {
|
|
3
|
+
export const toRefV31 = ({ ref, refType, stackTrail, context, nullable, readOnly, writeOnly, siblings }) => {
|
|
4
4
|
const { $ref, ...skipped } = ref;
|
|
5
5
|
if (!isEmpty(skipped)) {
|
|
6
6
|
context.logSkippedFields({ skipped, parent: ref, parentType: 'ref', stackTrail });
|
|
7
7
|
}
|
|
8
8
|
context.registerRef(stackTrail.clone(), $ref);
|
|
9
|
-
return context.withStackTrail(stackTrail, () => new OasRef({ refType, $ref, nullable }, context));
|
|
9
|
+
return context.withStackTrail(stackTrail, () => new OasRef({ ...siblings, refType, $ref, nullable, readOnly, writeOnly }, context));
|
|
10
10
|
};
|