@skmtc/core 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/CoreContext.js +22 -8
- package/esm/context/GenerateContext.d.ts +6 -5
- package/esm/context/GenerateContext.js +112 -38
- package/esm/context/ParseContext.d.ts +18 -1
- package/esm/context/ParseContext.js +102 -3
- package/esm/context/generateTypes.d.ts +33 -4
- package/esm/context/generateTypes.js +4 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- package/esm/context/tryParseAt.d.ts +4 -1
- package/esm/context/tryParseAt.js +10 -3
- package/esm/dsl/CustomValue.d.ts +4 -0
- package/esm/dsl/CustomValue.js +8 -0
- package/esm/dsl/Definition.d.ts +10 -0
- package/esm/dsl/Definition.js +14 -0
- package/esm/dsl/PendingDefinition.d.ts +47 -0
- package/esm/dsl/PendingDefinition.js +83 -0
- package/esm/dsl/model/ModelDriver.d.ts +55 -1
- package/esm/dsl/model/ModelDriver.js +228 -51
- package/esm/dsl/model/toModelEntry.d.ts +1 -1
- package/esm/dsl/model/toModelEntry.js +1 -1
- package/esm/dsl/model/types.d.ts +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/esm/dsl/webhook/WebhookDriver.js +1 -4
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
- package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/esm/enrichments/parseEnrichmentValue.js +32 -0
- package/esm/enrichments/readEnrichments.d.ts +5 -5
- package/esm/enrichments/readEnrichments.js +17 -7
- package/esm/helpers/collateExamples.js +15 -5
- package/esm/helpers/refFns.d.ts +6 -2
- package/esm/helpers/refFns.js +24 -7
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/oas/array/Array.d.ts +19 -0
- package/esm/oas/array/Array.js +47 -0
- package/esm/oas/boolean/Boolean.d.ts +19 -0
- package/esm/oas/boolean/Boolean.js +51 -8
- package/esm/oas/example/Example.d.ts +4 -0
- package/esm/oas/example/Example.js +8 -0
- package/esm/oas/header/Header.d.ts +4 -0
- package/esm/oas/header/Header.js +8 -0
- package/esm/oas/integer/Integer.d.ts +19 -0
- package/esm/oas/integer/Integer.js +49 -0
- package/esm/oas/link/Link.d.ts +4 -0
- package/esm/oas/link/Link.js +8 -0
- package/esm/oas/number/Number.d.ts +19 -0
- package/esm/oas/number/Number.js +49 -0
- package/esm/oas/object/Object.d.ts +19 -0
- package/esm/oas/object/Object.js +68 -18
- package/esm/oas/operation/Operation.d.ts +8 -1
- package/esm/oas/operation/Operation.js +18 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/esm/oas/operation/toEffectiveParameters.js +42 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/DanglingRefError.d.ts +22 -0
- package/esm/oas/ref/DanglingRefError.js +33 -0
- package/esm/oas/ref/Ref.d.ts +152 -25
- package/esm/oas/ref/Ref.js +414 -26
- package/esm/oas/requestBody/RequestBody.d.ts +4 -0
- package/esm/oas/requestBody/RequestBody.js +8 -0
- package/esm/oas/response/Response.d.ts +4 -0
- package/esm/oas/response/Response.js +8 -0
- package/esm/oas/schema/siblings.d.ts +127 -0
- package/esm/oas/schema/siblings.js +250 -0
- package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
- package/esm/oas/string/String.d.ts +19 -0
- package/esm/oas/string/String.js +47 -0
- package/esm/oas/union/Union.d.ts +32 -0
- package/esm/oas/union/Union.js +111 -0
- package/esm/oas/unknown/Unknown.d.ts +18 -0
- package/esm/oas/unknown/Unknown.js +38 -0
- package/esm/oas/void/Void.d.ts +4 -0
- package/esm/oas/void/Void.js +8 -0
- package/esm/oas/webhook/Webhook.d.ts +2 -2
- package/esm/oas/webhook/Webhook.js +4 -5
- package/esm/parse/allOfSystem.d.ts +32 -0
- package/esm/parse/allOfSystem.js +30 -0
- package/esm/parse/anyOfSystem.d.ts +68 -0
- package/esm/parse/anyOfSystem.js +107 -0
- package/esm/parse/securityRequirements.d.ts +6 -0
- package/esm/parse/securityRequirements.js +8 -0
- package/esm/parse/toSiblingKeywords.d.ts +28 -0
- package/esm/parse/toSiblingKeywords.js +109 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
- package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
- package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +6 -3
- package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +6 -3
- package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +6 -3
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +44 -0
- package/esm/types/Settings.js +9 -0
- package/package.json +5 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +6 -5
- package/script/context/GenerateContext.js +112 -38
- package/script/context/ParseContext.d.ts +18 -1
- package/script/context/ParseContext.js +102 -3
- package/script/context/generateTypes.d.ts +33 -4
- package/script/context/generateTypes.js +4 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- package/script/context/tryParseAt.d.ts +4 -1
- package/script/context/tryParseAt.js +10 -3
- package/script/dsl/CustomValue.d.ts +4 -0
- package/script/dsl/CustomValue.js +8 -0
- package/script/dsl/Definition.d.ts +10 -0
- package/script/dsl/Definition.js +14 -0
- package/script/dsl/PendingDefinition.d.ts +47 -0
- package/script/dsl/PendingDefinition.js +87 -0
- package/script/dsl/model/ModelDriver.d.ts +55 -1
- package/script/dsl/model/ModelDriver.js +231 -52
- package/script/dsl/model/toModelEntry.d.ts +1 -1
- package/script/dsl/model/toModelEntry.js +1 -1
- package/script/dsl/model/types.d.ts +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/script/dsl/webhook/WebhookDriver.js +1 -4
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
- package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/script/enrichments/parseEnrichmentValue.js +69 -0
- package/script/enrichments/readEnrichments.d.ts +5 -5
- package/script/enrichments/readEnrichments.js +17 -40
- package/script/helpers/collateExamples.js +15 -5
- package/script/helpers/refFns.d.ts +6 -2
- package/script/helpers/refFns.js +24 -7
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/oas/array/Array.d.ts +19 -0
- package/script/oas/array/Array.js +47 -0
- package/script/oas/boolean/Boolean.d.ts +19 -0
- package/script/oas/boolean/Boolean.js +51 -8
- package/script/oas/example/Example.d.ts +4 -0
- package/script/oas/example/Example.js +8 -0
- package/script/oas/header/Header.d.ts +4 -0
- package/script/oas/header/Header.js +8 -0
- package/script/oas/integer/Integer.d.ts +19 -0
- package/script/oas/integer/Integer.js +49 -0
- package/script/oas/link/Link.d.ts +4 -0
- package/script/oas/link/Link.js +8 -0
- package/script/oas/number/Number.d.ts +19 -0
- package/script/oas/number/Number.js +49 -0
- package/script/oas/object/Object.d.ts +19 -0
- package/script/oas/object/Object.js +68 -18
- package/script/oas/operation/Operation.d.ts +8 -1
- package/script/oas/operation/Operation.js +18 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/script/oas/operation/toEffectiveParameters.js +47 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/DanglingRefError.d.ts +22 -0
- package/script/oas/ref/DanglingRefError.js +37 -0
- package/script/oas/ref/Ref.d.ts +152 -25
- package/script/oas/ref/Ref.js +414 -26
- package/script/oas/requestBody/RequestBody.d.ts +4 -0
- package/script/oas/requestBody/RequestBody.js +8 -0
- package/script/oas/response/Response.d.ts +4 -0
- package/script/oas/response/Response.js +8 -0
- package/script/oas/schema/siblings.d.ts +127 -0
- package/script/oas/schema/siblings.js +305 -0
- package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/script/oas/securitySchemes/SecurityScheme.js +32 -0
- package/script/oas/string/String.d.ts +19 -0
- package/script/oas/string/String.js +47 -0
- package/script/oas/union/Union.d.ts +32 -0
- package/script/oas/union/Union.js +111 -0
- package/script/oas/unknown/Unknown.d.ts +18 -0
- package/script/oas/unknown/Unknown.js +38 -0
- package/script/oas/void/Void.d.ts +4 -0
- package/script/oas/void/Void.js +8 -0
- package/script/oas/webhook/Webhook.d.ts +2 -2
- package/script/oas/webhook/Webhook.js +4 -5
- package/script/parse/allOfSystem.d.ts +32 -0
- package/script/parse/allOfSystem.js +35 -0
- package/script/parse/anyOfSystem.d.ts +68 -0
- package/script/parse/anyOfSystem.js +116 -0
- package/script/parse/securityRequirements.d.ts +6 -0
- package/script/parse/securityRequirements.js +8 -0
- package/script/parse/toSiblingKeywords.d.ts +28 -0
- package/script/parse/toSiblingKeywords.js +146 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
- package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
- package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
- package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +6 -3
- package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +6 -3
- package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +6 -3
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +44 -0
- package/script/types/Settings.js +10 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { isEmpty } from '../helpers/isEmpty.js';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
/**
|
|
4
|
+
* The checks the type parsers make (`oasStringData`, `oasNumberData`, …) on
|
|
5
|
+
* the keywords that do not depend on the target's type. `default`, `enum`
|
|
6
|
+
* and `example` do, so `clone` checks them once the target is known.
|
|
7
|
+
*/
|
|
8
|
+
const SIBLING_CHECKS = {
|
|
9
|
+
title: v.string(),
|
|
10
|
+
description: v.string(),
|
|
11
|
+
deprecated: v.boolean(),
|
|
12
|
+
format: v.string(),
|
|
13
|
+
minLength: v.number(),
|
|
14
|
+
maxLength: v.number(),
|
|
15
|
+
pattern: v.string(),
|
|
16
|
+
multipleOf: v.number(),
|
|
17
|
+
minimum: v.number(),
|
|
18
|
+
maximum: v.number(),
|
|
19
|
+
// 3.1's numeric form is normalized to `minimum` plus `true` before this point.
|
|
20
|
+
exclusiveMinimum: v.boolean(),
|
|
21
|
+
exclusiveMaximum: v.boolean(),
|
|
22
|
+
minItems: v.number(),
|
|
23
|
+
maxItems: v.number(),
|
|
24
|
+
uniqueItems: v.boolean(),
|
|
25
|
+
required: v.array(v.string()),
|
|
26
|
+
minProperties: v.number(),
|
|
27
|
+
maxProperties: v.number()
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The keywords next to a reference in a one-member `allOf`, read without the
|
|
31
|
+
* target's type (see `SiblingKeywords`): the reference stays lazy, so the
|
|
32
|
+
* target may not be parsed yet. The ones the target cannot take are left out
|
|
33
|
+
* at generate time (`OasRef.toSkippedSiblings`). An extension (`x-*`) is kept, as each
|
|
34
|
+
* version's `toSpecificationExtensionsV3` keeps one; a keyword that no schema
|
|
35
|
+
* has here is reported. `undefined` when no keyword is left. Shared by the
|
|
36
|
+
* 3.0, 3.1 and 3.2 parsers.
|
|
37
|
+
*/
|
|
38
|
+
export const toSiblingKeywords = ({ keywords, properties, additionalProperties, stackTrail, context }) => {
|
|
39
|
+
const { properties: _properties, additionalProperties: _additionalProperties, type, title, description, deprecated, example, default: defaultValue, enum: enums, format, minLength, maxLength, pattern, multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, uniqueItems, required, minProperties, maxProperties, ...rest } = keywords;
|
|
40
|
+
const entries = Object.entries(rest);
|
|
41
|
+
const extensionFields = Object.fromEntries(entries.filter(([key]) => key.startsWith('x-')));
|
|
42
|
+
const skipped = Object.fromEntries(entries.filter(([key]) => !key.startsWith('x-')));
|
|
43
|
+
if (!isEmpty(skipped)) {
|
|
44
|
+
context.logSkippedFields({
|
|
45
|
+
skipped,
|
|
46
|
+
parent: keywords,
|
|
47
|
+
parentType: 'schema:siblings',
|
|
48
|
+
stackTrail
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (enums !== undefined && !Array.isArray(enums)) {
|
|
52
|
+
context.logIssue({
|
|
53
|
+
key: 'enum',
|
|
54
|
+
level: 'warning',
|
|
55
|
+
message: `Removed invalid enum. Expected an array, got: ${JSON.stringify(enums)}`,
|
|
56
|
+
parent: keywords,
|
|
57
|
+
stackTrail,
|
|
58
|
+
type: 'INVALID_ENUM'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// A value the type parsers would refuse is left out, with a warning: the
|
|
62
|
+
// rest of the site still parses, as a schema's other faults do.
|
|
63
|
+
const checked = (key, value) => {
|
|
64
|
+
if (value === undefined) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const result = v.safeParse(SIBLING_CHECKS[key], value);
|
|
68
|
+
if (result.success) {
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
context.logIssue({
|
|
72
|
+
key,
|
|
73
|
+
level: 'warning',
|
|
74
|
+
message: `Removed invalid ${key} next to a reference: ${result.issues[0].message}`,
|
|
75
|
+
parent: keywords,
|
|
76
|
+
stackTrail,
|
|
77
|
+
type: 'INVALID_SCHEMA'
|
|
78
|
+
});
|
|
79
|
+
return undefined;
|
|
80
|
+
};
|
|
81
|
+
const siblings = {
|
|
82
|
+
_type: type,
|
|
83
|
+
title: checked('title', title),
|
|
84
|
+
description: checked('description', description),
|
|
85
|
+
deprecated: checked('deprecated', deprecated),
|
|
86
|
+
example,
|
|
87
|
+
default: defaultValue,
|
|
88
|
+
enums: Array.isArray(enums) ? enums : undefined,
|
|
89
|
+
extensionFields: isEmpty(extensionFields) ? undefined : extensionFields,
|
|
90
|
+
format: checked('format', format),
|
|
91
|
+
minLength: checked('minLength', minLength),
|
|
92
|
+
maxLength: checked('maxLength', maxLength),
|
|
93
|
+
pattern: checked('pattern', pattern),
|
|
94
|
+
multipleOf: checked('multipleOf', multipleOf),
|
|
95
|
+
minimum: checked('minimum', minimum),
|
|
96
|
+
maximum: checked('maximum', maximum),
|
|
97
|
+
exclusiveMinimum: checked('exclusiveMinimum', exclusiveMinimum),
|
|
98
|
+
exclusiveMaximum: checked('exclusiveMaximum', exclusiveMaximum),
|
|
99
|
+
minItems: checked('minItems', minItems),
|
|
100
|
+
maxItems: checked('maxItems', maxItems),
|
|
101
|
+
uniqueItems: checked('uniqueItems', uniqueItems),
|
|
102
|
+
properties,
|
|
103
|
+
required: checked('required', required),
|
|
104
|
+
additionalProperties,
|
|
105
|
+
minProperties: checked('minProperties', minProperties),
|
|
106
|
+
maxProperties: checked('maxProperties', maxProperties)
|
|
107
|
+
};
|
|
108
|
+
return Object.values(siblings).some(value => value !== undefined) ? siblings : undefined;
|
|
109
|
+
};
|
|
@@ -9,4 +9,12 @@ type DecomposeUnionReturn = {
|
|
|
9
9
|
afterExcluded: SchemaObject;
|
|
10
10
|
};
|
|
11
11
|
export declare const decomposeUnion: ({ schema, groupType }: DecomposeUnionArgs) => DecomposeUnionReturn;
|
|
12
|
+
/**
|
|
13
|
+
* Is `key` a union-level key, kept on the union rather than merged into each
|
|
14
|
+
* member? A specification extension (`x-…`) is one too: it says something
|
|
15
|
+
* about the union, as Fern's `x-fern-property-name` renames the property,
|
|
16
|
+
* and `toUnion` keeps it. Merged into each member, it was lost, and each
|
|
17
|
+
* `$ref` member was resolved to merge it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isUnionLevelKey: (key: string) => boolean;
|
|
12
20
|
export {};
|
|
@@ -56,9 +56,17 @@ const excludedProperties = [
|
|
|
56
56
|
'writeOnly',
|
|
57
57
|
'deprecated'
|
|
58
58
|
];
|
|
59
|
+
/**
|
|
60
|
+
* Is `key` a union-level key, kept on the union rather than merged into each
|
|
61
|
+
* member? A specification extension (`x-…`) is one too: it says something
|
|
62
|
+
* about the union, as Fern's `x-fern-property-name` renames the property,
|
|
63
|
+
* and `toUnion` keeps it. Merged into each member, it was lost, and each
|
|
64
|
+
* `$ref` member was resolved to merge it.
|
|
65
|
+
*/
|
|
66
|
+
export const isUnionLevelKey = (key) => excludedProperties.includes(key) || key.startsWith('x-');
|
|
59
67
|
const exclude = (entries) => {
|
|
60
68
|
return entries.reduce((acc, [key, value]) => {
|
|
61
|
-
if (
|
|
69
|
+
if (isUnionLevelKey(key)) {
|
|
62
70
|
acc.excluded.push([key, value]);
|
|
63
71
|
}
|
|
64
72
|
else {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject,
|
|
2
|
-
|
|
3
|
-
export declare const genericMerge: <T>(first: SchemaObject, second: SchemaObject, getRef: GetRefFn, typeCheck?: v.GenericSchema<T>) => SchemaObject;
|
|
1
|
+
import type { SchemaObject, GenericMergeArgs } from './types.js';
|
|
2
|
+
export declare const genericMerge: <T>({ first, second, getRef, system, typeCheck }: GenericMergeArgs<T>) => SchemaObject;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeEnumValues } from './merge-enum-values.js';
|
|
2
2
|
import { mergeProperties } from './merge-properties.js';
|
|
3
3
|
import { mergeRequired } from './merge-required.js';
|
|
4
|
-
export const genericMerge = (first, second, getRef, typeCheck) => {
|
|
4
|
+
export const genericMerge = ({ first, second, getRef, system, typeCheck }) => {
|
|
5
5
|
return {
|
|
6
6
|
...first,
|
|
7
7
|
...second,
|
|
8
|
-
...mergeProperties(first, second, getRef),
|
|
8
|
+
...mergeProperties({ first, second, getRef, system }),
|
|
9
9
|
...mergeRequired(first, second),
|
|
10
10
|
...mergeEnumValues(first, second, typeCheck)
|
|
11
11
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ArraySchemaObject,
|
|
2
|
-
export declare function mergeArrayConstraints(first
|
|
1
|
+
import type { ArraySchemaObject, SchemaObject, MergeArgs } from './types.js';
|
|
2
|
+
export declare function mergeArrayConstraints({ first, second, getRef, system }: MergeArgs<ArraySchemaObject | SchemaObject>): ArraySchemaObject;
|
|
@@ -2,15 +2,15 @@ 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 function mergeArrayConstraints(first, second, getRef) {
|
|
5
|
+
export function mergeArrayConstraints({ first, second, getRef, system }) {
|
|
6
6
|
checkTypeConflicts(first, second);
|
|
7
7
|
if (!('items' in first) && !('items' in second)) {
|
|
8
8
|
throw new Error('Cannot merge array constraints: no items found');
|
|
9
9
|
}
|
|
10
10
|
const result = {
|
|
11
|
-
...genericMerge(first, second, getRef, v.array(v.any())),
|
|
11
|
+
...genericMerge({ first, second, getRef, system, typeCheck: v.array(v.any()) }),
|
|
12
12
|
type: 'array',
|
|
13
|
-
items: mergeItems(first, second, getRef)
|
|
13
|
+
items: mergeItems({ first, second, getRef, system })
|
|
14
14
|
};
|
|
15
15
|
// Merge minItems
|
|
16
16
|
if (first.minItems !== undefined || second.minItems !== undefined) {
|
|
@@ -30,9 +30,9 @@ export function mergeArrayConstraints(first, second, getRef) {
|
|
|
30
30
|
}
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
|
-
const mergeItems = (first, second, getRef) => {
|
|
33
|
+
const mergeItems = ({ first, second, getRef, system }) => {
|
|
34
34
|
if ('items' in first && 'items' in second && first.items && second.items) {
|
|
35
|
-
return mergeSchemasOrRefs(first.items, second.items, getRef);
|
|
35
|
+
return mergeSchemasOrRefs({ first: first.items, second: second.items, getRef, system });
|
|
36
36
|
}
|
|
37
37
|
if ('items' in first && first.items) {
|
|
38
38
|
return first.items;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function mergeBooleanConstraints(first
|
|
2
|
+
import type { MergeArgs } from './types.js';
|
|
3
|
+
export declare function mergeBooleanConstraints({ first, second, getRef, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { genericMerge } from './generic-merge.js';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { checkTypeConflicts } from './check-type-conflicts.js';
|
|
4
|
-
export function mergeBooleanConstraints(first, second, getRef) {
|
|
4
|
+
export function mergeBooleanConstraints({ first, second, getRef, system }) {
|
|
5
5
|
checkTypeConflicts(first, second);
|
|
6
|
-
return genericMerge(first, second, getRef, v.boolean());
|
|
6
|
+
return genericMerge({ first, second, getRef, system, typeCheck: v.boolean() });
|
|
7
7
|
}
|
|
@@ -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, 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) {
|
|
5
|
+
export function mergeIntegerConstraints({ 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 = 'integer';
|
|
11
11
|
mergeBounds(result, first, second);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { GetRefFn, SchemaOrReference, SchemaObject } from './types.js';
|
|
1
|
+
import type { GetRefFn, SchemaOrReference, SchemaObject, MergeSystem } from './types.js';
|
|
2
2
|
type MergeIntersectionArgs = {
|
|
3
3
|
schema: SchemaObject;
|
|
4
4
|
getRef: GetRefFn;
|
|
5
|
+
system: MergeSystem;
|
|
5
6
|
throwOnConflict?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const mergeIntersection: ({ schema, getRef }: MergeIntersectionArgs) => SchemaOrReference;
|
|
8
|
+
export declare const mergeIntersection: ({ schema, getRef, system }: MergeIntersectionArgs) => SchemaOrReference;
|
|
8
9
|
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 }) => {
|
|
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;
|