@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,6 +1,6 @@
|
|
|
1
1
|
import { decomposeIntersection } from './decompose-intersection.js';
|
|
2
2
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
3
|
-
export const mergeIntersection = ({ schema, getRef }) => {
|
|
3
|
+
export const mergeIntersection = ({ schema, getRef, 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 }) => {
|
|
|
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);
|
|
12
|
+
const merged = mergeSchemasOrRefs({ first: acc, second: decomposed, getRef, 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, 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) {
|
|
5
|
+
export function mergeNumberConstraints({ first, second, getRef, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
// First merge enum values if present
|
|
8
|
-
const result = genericMerge(first, second, getRef, v.number());
|
|
8
|
+
const result = genericMerge({ first, second, getRef, 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
3
|
type SchemaObject = OpenAPIV3.SchemaObject;
|
|
3
|
-
|
|
4
|
-
export declare const mergeObjectConstraints: (first: SchemaObject, second: SchemaObject, getRef: (ref: ReferenceObject) => SchemaObject) => SchemaObject;
|
|
4
|
+
export declare const mergeObjectConstraints: ({ first, second, getRef, 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) => {
|
|
5
|
+
export const mergeObjectConstraints = ({ first, second, getRef, system }) => {
|
|
6
6
|
// Check for type conflicts
|
|
7
7
|
checkTypeConflicts(first, second);
|
|
8
|
-
const result = genericMerge(first, second, getRef, v.record(v.string(), v.any()));
|
|
8
|
+
const result = genericMerge({ first, second, getRef, 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);
|
|
12
|
+
result.additionalProperties = mergeSchemasOrRefs({ first: first.additionalProperties, second: second.additionalProperties, getRef, 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, system }: MergeArgs<SchemaObject>) => SchemaObject | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeSchemasOrRefs } from './merge.js';
|
|
2
|
-
export const mergeProperties = (first, second, getRef) => {
|
|
2
|
+
export const mergeProperties = ({ first, second, getRef, 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) => {
|
|
|
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);
|
|
12
|
+
properties[key] = mergeSchemasOrRefs({ first: properties[key], second: second.properties[key], getRef, 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, 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) {
|
|
5
|
+
export function mergeStringConstraints({ first, second, getRef, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
if (!checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
8
|
-
return genericMerge(first, second, getRef);
|
|
8
|
+
return genericMerge({ first, second, getRef, system });
|
|
9
9
|
}
|
|
10
10
|
// First merge enum values if present
|
|
11
|
-
const result = genericMerge(first, second, getRef, v.string());
|
|
11
|
+
const result = genericMerge({ first, second, getRef, system, typeCheck: v.string() });
|
|
12
12
|
// Then merge other constraints
|
|
13
13
|
result.type = 'string';
|
|
14
14
|
// Merge minLength
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import type { GetRefFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeUnionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
|
+
system: MergeSystem;
|
|
5
6
|
groupType: 'oneOf' | 'anyOf';
|
|
6
7
|
};
|
|
7
|
-
export declare const mergeUnion: ({ schema, getRef, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
8
|
+
export declare const mergeUnion: ({ schema, getRef, system, groupType }: MergeUnionArgs) => SchemaOrReference;
|
|
8
9
|
type MergeCrossProductArgs = {
|
|
9
10
|
first: SchemaObject;
|
|
10
11
|
second: SchemaObject;
|
|
11
12
|
getRef: GetRefFn;
|
|
13
|
+
system: MergeSystem;
|
|
12
14
|
groupType: 'oneOf' | 'anyOf';
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
18
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
19
|
+
*/
|
|
20
|
+
export declare const toOwnSystem: (system: MergeSystem) => MergeSystem;
|
|
21
|
+
export declare const mergeCrossProduct: ({ first, second, getRef, system, groupType }: MergeCrossProductArgs) => SchemaObject;
|
|
15
22
|
export {};
|
|
@@ -2,7 +2,7 @@ import { decomposeUnion } 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, groupType }) => {
|
|
5
|
+
export const mergeUnion = ({ schema, getRef, 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))
|
|
@@ -18,7 +18,7 @@ export const mergeUnion = ({ schema, getRef, groupType }) => {
|
|
|
18
18
|
return '$ref' in decomposed ? getRef(decomposed) : decomposed;
|
|
19
19
|
});
|
|
20
20
|
const result = dereffed.reduce((acc, decomposed) => {
|
|
21
|
-
const merged = mergeCrossProduct({ first: acc, second: decomposed, getRef, groupType });
|
|
21
|
+
const merged = mergeCrossProduct({ first: acc, second: decomposed, getRef, system, groupType });
|
|
22
22
|
return merged;
|
|
23
23
|
}, {});
|
|
24
24
|
const output = {
|
|
@@ -28,20 +28,58 @@ export const mergeUnion = ({ schema, getRef, groupType }) => {
|
|
|
28
28
|
};
|
|
29
29
|
return output;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The `system` a member's own `allOf` merges under: the `client.json`
|
|
33
|
+
* setting, also in the first pass over a cross product's pairs.
|
|
34
|
+
*/
|
|
35
|
+
export const toOwnSystem = (system) => ({
|
|
36
|
+
...system,
|
|
37
|
+
allOf: system.setting ?? system.allOf,
|
|
38
|
+
setting: undefined
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* The merge of each pair of the cross product whose members do not
|
|
42
|
+
* contradict. Such a pair is no value of the union, so it is left out, as
|
|
43
|
+
* under `strict`. Only when every pair contradicts does `latestWins` merge
|
|
44
|
+
* them again, the later member winning, without duplicates: Cloudflare's
|
|
45
|
+
* collections say `result` is an object or a string, then an array.
|
|
46
|
+
*
|
|
47
|
+
* The first pass is strict between the two members of a pair only. A
|
|
48
|
+
* member's own `allOf` merges under the `client.json` setting
|
|
49
|
+
* ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
|
|
50
|
+
* cross product with no pair that merges fails its pair: the outer pass then
|
|
51
|
+
* leaves the pair out, or lets the later member win.
|
|
52
|
+
*/
|
|
53
|
+
const mergePairs = ({ pairs, merge, system }) => {
|
|
54
|
+
const mergeEach = (pairSystem) => pairs.flatMap(pair => {
|
|
36
55
|
try {
|
|
37
|
-
|
|
38
|
-
return result;
|
|
56
|
+
return [merge(pair, pairSystem)];
|
|
39
57
|
}
|
|
40
58
|
catch (_error) {
|
|
41
|
-
return
|
|
59
|
+
return [];
|
|
42
60
|
}
|
|
43
|
-
})
|
|
44
|
-
|
|
61
|
+
});
|
|
62
|
+
const strict = mergeEach({ ...system, allOf: 'strict', setting: system.setting ?? system.allOf });
|
|
63
|
+
if (strict.length > 0) {
|
|
64
|
+
return strict;
|
|
65
|
+
}
|
|
66
|
+
if (system.allOf === 'strict' && system.setting === 'latestWins') {
|
|
67
|
+
throw new Error('No pair of the cross product merges');
|
|
68
|
+
}
|
|
69
|
+
if (system.allOf === 'strict') {
|
|
70
|
+
return strict;
|
|
71
|
+
}
|
|
72
|
+
const latest = mergeEach(system).map(item => ({ item, key: JSON.stringify(item) }));
|
|
73
|
+
return latest.filter(({ key }, index) => latest.findIndex(other => other.key === key) === index).map(({ item }) => item);
|
|
74
|
+
};
|
|
75
|
+
export const mergeCrossProduct = ({ first, second, getRef, system, groupType }) => {
|
|
76
|
+
const firstGroup = Array.isArray(first[groupType]) ? first[groupType] : [first];
|
|
77
|
+
const secondGroup = Array.isArray(second[groupType]) ? second[groupType] : [second];
|
|
78
|
+
const mergedGroup = mergePairs({
|
|
79
|
+
pairs: crossProduct(firstGroup, secondGroup),
|
|
80
|
+
merge: ([firstItem, secondItem], pairSystem) => mergeSchemasOrRefs({ first: firstItem, second: secondItem, getRef, system: pairSystem }),
|
|
81
|
+
system
|
|
82
|
+
});
|
|
45
83
|
return {
|
|
46
84
|
[groupType]: mergedGroup.flatMap(item => {
|
|
47
85
|
if (!isRef(item) && Array.isArray(item[groupType])) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { SchemaOrReference,
|
|
2
|
-
export declare const mergeSchemasOrRefs: (first
|
|
1
|
+
import type { SchemaOrReference, MergeArgs } from './types.js';
|
|
2
|
+
export declare const mergeSchemasOrRefs: ({ first, second, getRef, system }: MergeArgs<SchemaOrReference>) => SchemaOrReference;
|
|
@@ -14,12 +14,13 @@ 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 { mergeCrossProduct } from './merge-union.js';
|
|
17
|
+
import { 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, second, getRef, system }) => {
|
|
21
22
|
if (containsRef(first, second)) {
|
|
22
|
-
return mergeWithRef(first, second, getRef);
|
|
23
|
+
return mergeWithRef({ first, second, getRef, system });
|
|
23
24
|
}
|
|
24
25
|
if (isRef(first)) {
|
|
25
26
|
throw new Error('Ref in first');
|
|
@@ -27,18 +28,30 @@ export const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
27
28
|
if (isRef(second)) {
|
|
28
29
|
throw new Error('Ref in second');
|
|
29
30
|
}
|
|
31
|
+
// Under `system.anyOf: unknown` an `anyOf` of two or more members is any
|
|
32
|
+
// value, so it adds nothing to the merge: its members are left out, and the
|
|
33
|
+
// keywords next to it merge as usual.
|
|
34
|
+
const firstKeywords = withoutUnknownAnyOf({ schema: first, setting: system.anyOf, getRef });
|
|
35
|
+
const secondKeywords = withoutUnknownAnyOf({ schema: second, setting: system.anyOf, getRef });
|
|
36
|
+
if (firstKeywords !== first || secondKeywords !== second) {
|
|
37
|
+
system.unknown?.add('anyOf');
|
|
38
|
+
return mergeSchemasOrRefs({ first: firstKeywords, second: secondKeywords, getRef, system });
|
|
39
|
+
}
|
|
30
40
|
if (containsAllOf(first) || containsAllOf(second)) {
|
|
31
|
-
|
|
41
|
+
// Each member's own `allOf` merges under the `client.json` setting, also in
|
|
42
|
+
// the strict first pass over a cross product's pairs.
|
|
43
|
+
const ownSystem = toOwnSystem(system);
|
|
44
|
+
const mergedFirst = containsAllOf(first) ? mergeIntersection({ schema: first, getRef, system: ownSystem }) : first;
|
|
32
45
|
const mergedSecond = containsAllOf(second)
|
|
33
|
-
? mergeIntersection({ schema: second, getRef })
|
|
46
|
+
? mergeIntersection({ schema: second, getRef, system: ownSystem })
|
|
34
47
|
: second;
|
|
35
|
-
return mergeSchemasOrRefs(mergedFirst, mergedSecond, getRef);
|
|
48
|
+
return mergeSchemasOrRefs({ first: mergedFirst, second: mergedSecond, getRef, system });
|
|
36
49
|
}
|
|
37
50
|
if (containsOneOf(first, second)) {
|
|
38
|
-
return mergeCrossProduct({ first, second, getRef, groupType: 'oneOf' });
|
|
51
|
+
return mergeCrossProduct({ first, second, getRef, system, groupType: 'oneOf' });
|
|
39
52
|
}
|
|
40
53
|
if (containsAnyOf(first, second)) {
|
|
41
|
-
return mergeCrossProduct({ first, second, getRef, groupType: 'anyOf' });
|
|
54
|
+
return mergeCrossProduct({ first, second, getRef, system, groupType: 'anyOf' });
|
|
42
55
|
}
|
|
43
56
|
if (isNullOnly(first)) {
|
|
44
57
|
return mergeNullOnly(second);
|
|
@@ -46,7 +59,7 @@ export const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
46
59
|
if (isNullOnly(second)) {
|
|
47
60
|
return mergeNullOnly(first);
|
|
48
61
|
}
|
|
49
|
-
return mergeSchemas(first, second, getRef);
|
|
62
|
+
return mergeSchemas({ first, second, getRef, system });
|
|
50
63
|
};
|
|
51
64
|
const containsAllOf = (schema) => {
|
|
52
65
|
if (schema.allOf) {
|
|
@@ -90,48 +103,83 @@ const containsOneOf = (first, second) => {
|
|
|
90
103
|
const containsRef = (first, second) => {
|
|
91
104
|
return isRef(first) || isRef(second);
|
|
92
105
|
};
|
|
93
|
-
|
|
106
|
+
/** Whether one member says `number` and the other `integer`. */
|
|
107
|
+
const isNumberAndInteger = (first, second) => (first.type === 'number' && second.type === 'integer') || (first.type === 'integer' && second.type === 'number');
|
|
108
|
+
const mergeSchemas = ({ first, second, getRef, system }) => {
|
|
109
|
+
// Every integer is a number, so a `number` merged with an `integer` is an
|
|
110
|
+
// `integer` with the constraints of both. Nothing contradicts.
|
|
111
|
+
if (isNumberAndInteger(first, second)) {
|
|
112
|
+
return mergeSchemas({ first: { ...first, type: 'integer' }, second: { ...second, type: 'integer' }, getRef, system });
|
|
113
|
+
}
|
|
114
|
+
if (system.allOf === 'latestWins') {
|
|
115
|
+
// The later member wins a contradiction: a type it disagrees with makes
|
|
116
|
+
// it the whole schema, and any other keyword it disagrees with is left
|
|
117
|
+
// out of the earlier member before they merge.
|
|
118
|
+
if (first.type && second.type && first.type !== second.type) {
|
|
119
|
+
system.replaced.add('type');
|
|
120
|
+
return second;
|
|
121
|
+
}
|
|
122
|
+
const earlier = withoutContradictions({ first, second, replaced: system.replaced });
|
|
123
|
+
return mergeChecked({ first: earlier, second, getRef, system });
|
|
124
|
+
}
|
|
125
|
+
return mergeChecked({ first, second, getRef, system });
|
|
126
|
+
};
|
|
127
|
+
const CONTRADICTIONS = [
|
|
128
|
+
{ check: checkReadOnlyWriteOnlyConflicts, keywords: ['readOnly', 'writeOnly'] },
|
|
129
|
+
{ check: checkFormatConflicts, keywords: ['format'] },
|
|
130
|
+
{ check: checkEnumConflicts, keywords: ['enum'] },
|
|
131
|
+
{ check: checkNumberConstraintsConflicts, keywords: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'] },
|
|
132
|
+
{ check: checkArrayItemTypeConflicts, keywords: ['items'] }
|
|
133
|
+
];
|
|
134
|
+
/** `first` without the keywords that contradict `second`, each named in `replaced`. */
|
|
135
|
+
const withoutContradictions = ({ first, second, replaced }) => CONTRADICTIONS.reduce((earlier, { check, keywords }) => {
|
|
94
136
|
try {
|
|
95
|
-
|
|
137
|
+
check(earlier, second);
|
|
138
|
+
return earlier;
|
|
96
139
|
}
|
|
97
|
-
catch
|
|
98
|
-
|
|
140
|
+
catch {
|
|
141
|
+
const entries = Object.entries(earlier);
|
|
142
|
+
entries.filter(([key, value]) => keywords.includes(key) && value !== undefined).forEach(([key]) => replaced.add(key));
|
|
143
|
+
return Object.fromEntries(entries.filter(([key]) => !keywords.includes(key)));
|
|
99
144
|
}
|
|
145
|
+
}, first);
|
|
146
|
+
const mergeChecked = ({ first, second, getRef, system }) => {
|
|
147
|
+
checkTypeConflicts(first, second);
|
|
100
148
|
checkReadOnlyWriteOnlyConflicts(first, second);
|
|
101
149
|
checkFormatConflicts(first, second);
|
|
102
150
|
checkEnumConflicts(first, second);
|
|
103
151
|
checkNumberConstraintsConflicts(first, second);
|
|
104
152
|
checkArrayItemTypeConflicts(first, second);
|
|
105
|
-
if (first.not || second.not) {
|
|
153
|
+
if ((first.not || second.not) && system.not !== 'unknown') {
|
|
106
154
|
throw new Error('Merging schemas with "not" keyword is not supported');
|
|
107
155
|
}
|
|
108
|
-
return typedMerge(first, second, getRef);
|
|
156
|
+
return typedMerge({ first, second, getRef, system });
|
|
109
157
|
};
|
|
110
|
-
const typedMerge = (first, second, getRef) => {
|
|
158
|
+
const typedMerge = ({ first, second, getRef, system }) => {
|
|
111
159
|
if (!first.type && !second.type) {
|
|
112
|
-
return genericMerge(first, second, getRef);
|
|
160
|
+
return genericMerge({ first, second, getRef, system });
|
|
113
161
|
}
|
|
114
162
|
if (checkAtLeastOneTypeMatch(first, second, 'object')) {
|
|
115
|
-
return mergeObjectConstraints(first, second, getRef);
|
|
163
|
+
return mergeObjectConstraints({ first, second, getRef, system });
|
|
116
164
|
}
|
|
117
165
|
if (checkAtLeastOneTypeMatch(first, second, 'array')) {
|
|
118
|
-
return mergeArrayConstraints(first, second, getRef);
|
|
166
|
+
return mergeArrayConstraints({ first, second, getRef, system });
|
|
119
167
|
}
|
|
120
168
|
if (checkAtLeastOneTypeMatch(first, second, 'string')) {
|
|
121
|
-
return mergeStringConstraints(first, second, getRef);
|
|
169
|
+
return mergeStringConstraints({ first, second, getRef, system });
|
|
122
170
|
}
|
|
123
171
|
if (checkAtLeastOneTypeMatch(first, second, 'number')) {
|
|
124
|
-
return mergeNumberConstraints(first, second, getRef);
|
|
172
|
+
return mergeNumberConstraints({ first, second, getRef, system });
|
|
125
173
|
}
|
|
126
174
|
if (checkAtLeastOneTypeMatch(first, second, 'integer')) {
|
|
127
|
-
return mergeIntegerConstraints(first, second, getRef);
|
|
175
|
+
return mergeIntegerConstraints({ first, second, getRef, system });
|
|
128
176
|
}
|
|
129
177
|
if (checkAtLeastOneTypeMatch(first, second, 'boolean')) {
|
|
130
|
-
return mergeBooleanConstraints(first, second, getRef);
|
|
178
|
+
return mergeBooleanConstraints({ first, second, getRef, system });
|
|
131
179
|
}
|
|
132
180
|
throw new Error(`Cannot merge schemas with type "${first.type}" with type "${second.type}"`);
|
|
133
181
|
};
|
|
134
|
-
const mergeWithRef = (first, second, getRef) => {
|
|
182
|
+
const mergeWithRef = ({ first, second, getRef, system }) => {
|
|
135
183
|
if (isRef(first) && isRef(second)) {
|
|
136
184
|
if (first.$ref === second.$ref) {
|
|
137
185
|
return {
|
|
@@ -140,15 +188,18 @@ const mergeWithRef = (first, second, getRef) => {
|
|
|
140
188
|
};
|
|
141
189
|
}
|
|
142
190
|
else {
|
|
143
|
-
return
|
|
191
|
+
return mergeSchemasOrRefs({ first: getRef(first), second: getRef(second), getRef, system });
|
|
144
192
|
}
|
|
145
193
|
}
|
|
194
|
+
// A target followed through its reference merges as any schema does: a
|
|
195
|
+
// `oneOf` or `anyOf` in either one is crossed with the other, not kept
|
|
196
|
+
// beside the merged properties.
|
|
146
197
|
if (isRef(first) && !isRef(second)) {
|
|
147
|
-
const merged = isEmpty(second) ? first :
|
|
198
|
+
const merged = isEmpty(second) ? first : mergeSchemasOrRefs({ first: getRef(first), second, getRef, system });
|
|
148
199
|
return merged;
|
|
149
200
|
}
|
|
150
201
|
if (!isRef(first) && isRef(second)) {
|
|
151
|
-
const merged = isEmpty(first) ? second :
|
|
202
|
+
const merged = isEmpty(first) ? second : mergeSchemasOrRefs({ first, second: getRef(second), getRef, system });
|
|
152
203
|
return merged;
|
|
153
204
|
}
|
|
154
205
|
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 ?? {}));
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
4
|
+
/**
|
|
5
|
+
* The `system` settings as the merge reads them (`client.json#settings.system`),
|
|
6
|
+
* and the keywords a later `allOf` member replaced under `latestWins`, so
|
|
7
|
+
* the parser can name them in one warning for the schema.
|
|
8
|
+
*/
|
|
9
|
+
export type MergeSystem = {
|
|
10
|
+
/** `strict`: a contradiction between members fails the merge. `latestWins`: the later member's keyword wins. */
|
|
11
|
+
allOf: 'strict' | 'latestWins';
|
|
12
|
+
/** `unknown`: a member with `not` merges, its `not` carried as written. Left out: `strict`, which refuses it. */
|
|
13
|
+
not?: 'strict' | 'unknown';
|
|
14
|
+
/**
|
|
15
|
+
* `client.json` `system.allOf`, kept while the first pass over a cross
|
|
16
|
+
* product's pairs sets `allOf` to `strict`. A member's own `allOf` merges
|
|
17
|
+
* under this setting in every pass. Left out: `allOf` is the setting.
|
|
18
|
+
*/
|
|
19
|
+
setting?: 'strict' | 'latestWins';
|
|
20
|
+
replaced: Set<string>;
|
|
21
|
+
/** `unknown`: an `anyOf` of two or more members is any value, so it adds nothing to the merge. Left out: `union`. */
|
|
22
|
+
anyOf?: 'union' | 'unknown';
|
|
23
|
+
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
24
|
+
unknown?: Set<string>;
|
|
25
|
+
};
|
|
4
26
|
export type OneOfObject = {
|
|
5
27
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
6
28
|
} & OpenAPIV3.SchemaObject;
|
|
@@ -10,5 +32,16 @@ export type AnyOfObject = {
|
|
|
10
32
|
export type SchemaObject = OpenAPIV3.SchemaObject;
|
|
11
33
|
export type ReferenceObject = OpenAPIV3.ReferenceObject;
|
|
12
34
|
export type SchemaOrReference = SchemaObject | ReferenceObject;
|
|
35
|
+
/** Two schemas to merge, how to follow a reference, and the `system` settings: what each merge step takes. */
|
|
36
|
+
export type MergeArgs<Schema = SchemaOrReference> = {
|
|
37
|
+
first: Schema;
|
|
38
|
+
second: Schema;
|
|
39
|
+
getRef: GetRefFn;
|
|
40
|
+
system: MergeSystem;
|
|
41
|
+
};
|
|
42
|
+
/** {@link MergeArgs}, and the valibot schema `default`, `enum` and `example` values must pass. */
|
|
43
|
+
export type GenericMergeArgs<T> = MergeArgs<SchemaObject> & {
|
|
44
|
+
typeCheck?: v.GenericSchema<T>;
|
|
45
|
+
};
|
|
13
46
|
export type ArraySchemaObject = OpenAPIV3.ArraySchemaObject;
|
|
14
47
|
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
|
};
|