@skmtc/core 0.39.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
|
@@ -20,7 +20,8 @@ const merge_intersection_js_1 = require("./merge-intersection.js");
|
|
|
20
20
|
const merge_union_js_1 = require("./merge-union.js");
|
|
21
21
|
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
22
22
|
const nullable_merge_js_1 = require("./nullable-merge.js");
|
|
23
|
-
const
|
|
23
|
+
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
24
|
+
const mergeSchemasOrRefs = ({ first: inputFirst, second: inputSecond, getRef, normalize, system }) => {
|
|
24
25
|
const first = (0, refFns_js_1.isRef)(inputFirst)
|
|
25
26
|
? inputFirst
|
|
26
27
|
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputFirst), normalize);
|
|
@@ -28,7 +29,7 @@ const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) => {
|
|
|
28
29
|
? inputSecond
|
|
29
30
|
: (0, merge_union_js_1.collapseNullOnlyUnion)(normalize(inputSecond), normalize);
|
|
30
31
|
if (containsRef(first, second)) {
|
|
31
|
-
return mergeWithRef(first, second, getRef, normalize);
|
|
32
|
+
return mergeWithRef({ first, second, getRef, normalize, system });
|
|
32
33
|
}
|
|
33
34
|
if ((0, refFns_js_1.isRef)(first)) {
|
|
34
35
|
throw new Error('Ref in first');
|
|
@@ -36,20 +37,32 @@ const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) => {
|
|
|
36
37
|
if ((0, refFns_js_1.isRef)(second)) {
|
|
37
38
|
throw new Error('Ref in second');
|
|
38
39
|
}
|
|
40
|
+
// Under `system.anyOf: unknown` an `anyOf` of two or more members is any
|
|
41
|
+
// value, so it adds nothing to the merge: its members are left out, and the
|
|
42
|
+
// keywords next to it merge as usual.
|
|
43
|
+
const firstKeywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({ schema: first, setting: system.anyOf, getRef });
|
|
44
|
+
const secondKeywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({ schema: second, setting: system.anyOf, getRef });
|
|
45
|
+
if (firstKeywords !== first || secondKeywords !== second) {
|
|
46
|
+
system.unknown?.add('anyOf');
|
|
47
|
+
return (0, exports.mergeSchemasOrRefs)({ first: firstKeywords, second: secondKeywords, getRef, normalize, system });
|
|
48
|
+
}
|
|
39
49
|
if (containsAllOf(first) || containsAllOf(second)) {
|
|
50
|
+
// Each member's own `allOf` merges under the `client.json` setting, also in
|
|
51
|
+
// the strict first pass over a cross product's pairs.
|
|
52
|
+
const ownSystem = (0, merge_union_js_1.toOwnSystem)(system);
|
|
40
53
|
const mergedFirst = containsAllOf(first)
|
|
41
|
-
? (0, merge_intersection_js_1.mergeIntersection)({ schema: first, getRef, normalize })
|
|
54
|
+
? (0, merge_intersection_js_1.mergeIntersection)({ schema: first, getRef, normalize, system: ownSystem })
|
|
42
55
|
: first;
|
|
43
56
|
const mergedSecond = containsAllOf(second)
|
|
44
|
-
? (0, merge_intersection_js_1.mergeIntersection)({ schema: second, getRef, normalize })
|
|
57
|
+
? (0, merge_intersection_js_1.mergeIntersection)({ schema: second, getRef, normalize, system: ownSystem })
|
|
45
58
|
: second;
|
|
46
|
-
return (0, exports.mergeSchemasOrRefs)(mergedFirst, mergedSecond, getRef, normalize);
|
|
59
|
+
return (0, exports.mergeSchemasOrRefs)({ first: mergedFirst, second: mergedSecond, getRef, normalize, system });
|
|
47
60
|
}
|
|
48
61
|
if (containsOneOf(first, second)) {
|
|
49
|
-
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, normalize, groupType: 'oneOf' });
|
|
62
|
+
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, normalize, system, groupType: 'oneOf' });
|
|
50
63
|
}
|
|
51
64
|
if (containsAnyOf(first, second)) {
|
|
52
|
-
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, normalize, groupType: 'anyOf' });
|
|
65
|
+
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, normalize, system, groupType: 'anyOf' });
|
|
53
66
|
}
|
|
54
67
|
if ((0, nullable_merge_js_1.isNullOnly)(first)) {
|
|
55
68
|
return (0, nullable_merge_js_1.mergeNullOnly)(second);
|
|
@@ -57,7 +70,7 @@ const mergeSchemasOrRefs = (inputFirst, inputSecond, getRef, normalize) => {
|
|
|
57
70
|
if ((0, nullable_merge_js_1.isNullOnly)(second)) {
|
|
58
71
|
return (0, nullable_merge_js_1.mergeNullOnly)(first);
|
|
59
72
|
}
|
|
60
|
-
return mergeSchemas(first, second, getRef, normalize);
|
|
73
|
+
return mergeSchemas({ first, second, getRef, normalize, system });
|
|
61
74
|
};
|
|
62
75
|
exports.mergeSchemasOrRefs = mergeSchemasOrRefs;
|
|
63
76
|
const containsAllOf = (schema) => {
|
|
@@ -102,48 +115,91 @@ const containsOneOf = (first, second) => {
|
|
|
102
115
|
const containsRef = (first, second) => {
|
|
103
116
|
return (0, refFns_js_1.isRef)(first) || (0, refFns_js_1.isRef)(second);
|
|
104
117
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
/** Whether one member says `number` and the other `integer`. */
|
|
119
|
+
const isNumberAndInteger = (first, second) => (first.type === 'number' && second.type === 'integer') || (first.type === 'integer' && second.type === 'number');
|
|
120
|
+
const mergeSchemas = ({ first, second, getRef, normalize, system }) => {
|
|
121
|
+
// Every integer is a number, so a `number` merged with an `integer` is an
|
|
122
|
+
// `integer` with the constraints of both. Nothing contradicts.
|
|
123
|
+
if (isNumberAndInteger(first, second)) {
|
|
124
|
+
return mergeSchemas({
|
|
125
|
+
first: { ...first, type: 'integer' },
|
|
126
|
+
second: { ...second, type: 'integer' },
|
|
127
|
+
getRef,
|
|
128
|
+
normalize,
|
|
129
|
+
system
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (system.allOf === 'latestWins') {
|
|
133
|
+
// The later member wins a contradiction: a type it disagrees with makes
|
|
134
|
+
// it the whole schema, and any other keyword it disagrees with is left
|
|
135
|
+
// out of the earlier member before they merge.
|
|
136
|
+
if (first.type && second.type && first.type !== second.type) {
|
|
137
|
+
system.replaced.add('type');
|
|
138
|
+
return second;
|
|
139
|
+
}
|
|
140
|
+
const earlier = withoutContradictions({ first, second, normalize, replaced: system.replaced });
|
|
141
|
+
return mergeChecked({ first: earlier, second, getRef, normalize, system });
|
|
111
142
|
}
|
|
143
|
+
return mergeChecked({ first, second, getRef, normalize, system });
|
|
144
|
+
};
|
|
145
|
+
/** `first` without the keywords that contradict `second`, each named in `replaced`. */
|
|
146
|
+
const withoutContradictions = ({ first, second, normalize, replaced }) => {
|
|
147
|
+
const contradictions = [
|
|
148
|
+
{ check: check_read_only_write_only_conflicts_js_1.checkReadOnlyWriteOnlyConflicts, keywords: ['readOnly', 'writeOnly'] },
|
|
149
|
+
{ check: check_format_conflicts_js_1.checkFormatConflicts, keywords: ['format'] },
|
|
150
|
+
{ check: check_enum_conflicts_js_1.checkEnumConflicts, keywords: ['enum'] },
|
|
151
|
+
{ check: check_number_constraints_conflicts_js_1.checkNumberConstraintsConflicts, keywords: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'] },
|
|
152
|
+
{ check: (a, b) => (0, check_array_item_type_conflicts_js_1.checkArrayItemTypeConflicts)(a, b, normalize), keywords: ['items'] }
|
|
153
|
+
];
|
|
154
|
+
return contradictions.reduce((earlier, { check, keywords }) => {
|
|
155
|
+
try {
|
|
156
|
+
check(earlier, second);
|
|
157
|
+
return earlier;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
const entries = Object.entries(earlier);
|
|
161
|
+
entries.filter(([key, value]) => keywords.includes(key) && value !== undefined).forEach(([key]) => replaced.add(key));
|
|
162
|
+
return Object.fromEntries(entries.filter(([key]) => !keywords.includes(key)));
|
|
163
|
+
}
|
|
164
|
+
}, first);
|
|
165
|
+
};
|
|
166
|
+
const mergeChecked = ({ first, second, getRef, normalize, system }) => {
|
|
167
|
+
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
112
168
|
(0, check_read_only_write_only_conflicts_js_1.checkReadOnlyWriteOnlyConflicts)(first, second);
|
|
113
169
|
(0, check_format_conflicts_js_1.checkFormatConflicts)(first, second);
|
|
114
170
|
(0, check_enum_conflicts_js_1.checkEnumConflicts)(first, second);
|
|
115
171
|
(0, check_number_constraints_conflicts_js_1.checkNumberConstraintsConflicts)(first, second);
|
|
116
172
|
(0, check_array_item_type_conflicts_js_1.checkArrayItemTypeConflicts)(first, second, normalize);
|
|
117
|
-
if (first.not || second.not) {
|
|
173
|
+
if ((first.not || second.not) && system.not !== 'unknown') {
|
|
118
174
|
throw new Error('Merging schemas with "not" keyword is not supported');
|
|
119
175
|
}
|
|
120
|
-
return typedMerge(first, second, getRef, normalize);
|
|
176
|
+
return typedMerge({ first, second, getRef, normalize, system });
|
|
121
177
|
};
|
|
122
|
-
const typedMerge = (first, second, getRef, normalize) => {
|
|
178
|
+
const typedMerge = ({ first, second, getRef, normalize, system }) => {
|
|
123
179
|
if (!first.type && !second.type) {
|
|
124
|
-
return (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize);
|
|
180
|
+
return (0, generic_merge_js_1.genericMerge)({ first, second, getRef, normalize, system });
|
|
125
181
|
}
|
|
126
182
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'object')) {
|
|
127
|
-
return (0, merge_object_constraints_js_1.mergeObjectConstraints)(first, second, getRef, normalize);
|
|
183
|
+
return (0, merge_object_constraints_js_1.mergeObjectConstraints)({ first, second, getRef, normalize, system });
|
|
128
184
|
}
|
|
129
185
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'array')) {
|
|
130
|
-
return (0, merge_array_constraints_js_1.mergeArrayConstraints)(first, second, getRef, normalize);
|
|
186
|
+
return (0, merge_array_constraints_js_1.mergeArrayConstraints)({ first, second, getRef, normalize, system });
|
|
131
187
|
}
|
|
132
188
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'string')) {
|
|
133
|
-
return (0, merge_string_constraints_js_1.mergeStringConstraints)(first, second, getRef, normalize);
|
|
189
|
+
return (0, merge_string_constraints_js_1.mergeStringConstraints)({ first, second, getRef, normalize, system });
|
|
134
190
|
}
|
|
135
191
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'number')) {
|
|
136
|
-
return (0, merge_number_constraints_js_1.mergeNumberConstraints)(first, second, getRef, normalize);
|
|
192
|
+
return (0, merge_number_constraints_js_1.mergeNumberConstraints)({ first, second, getRef, normalize, system });
|
|
137
193
|
}
|
|
138
194
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'integer')) {
|
|
139
|
-
return (0, merge_integer_constraints_js_1.mergeIntegerConstraints)(first, second, getRef, normalize);
|
|
195
|
+
return (0, merge_integer_constraints_js_1.mergeIntegerConstraints)({ first, second, getRef, normalize, system });
|
|
140
196
|
}
|
|
141
197
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'boolean')) {
|
|
142
|
-
return (0, merge_boolean_constraints_js_1.mergeBooleanConstraints)(first, second, getRef, normalize);
|
|
198
|
+
return (0, merge_boolean_constraints_js_1.mergeBooleanConstraints)({ first, second, getRef, normalize, system });
|
|
143
199
|
}
|
|
144
200
|
throw new Error(`Cannot merge schemas with type "${first.type}" with type "${second.type}"`);
|
|
145
201
|
};
|
|
146
|
-
const mergeWithRef = (first, second, getRef, normalize) => {
|
|
202
|
+
const mergeWithRef = ({ first, second, getRef, normalize, system }) => {
|
|
147
203
|
const readRef = (ref) => normalize(getRef(ref));
|
|
148
204
|
if ((0, refFns_js_1.isRef)(first) && (0, refFns_js_1.isRef)(second)) {
|
|
149
205
|
if (first.$ref === second.$ref) {
|
|
@@ -153,15 +209,18 @@ const mergeWithRef = (first, second, getRef, normalize) => {
|
|
|
153
209
|
};
|
|
154
210
|
}
|
|
155
211
|
else {
|
|
156
|
-
return
|
|
212
|
+
return (0, exports.mergeSchemasOrRefs)({ first: readRef(first), second: readRef(second), getRef, normalize, system });
|
|
157
213
|
}
|
|
158
214
|
}
|
|
215
|
+
// A target followed through its reference merges as any schema does: a
|
|
216
|
+
// `oneOf` or `anyOf` in either one is crossed with the other, not kept
|
|
217
|
+
// beside the merged properties.
|
|
159
218
|
if ((0, refFns_js_1.isRef)(first) && !(0, refFns_js_1.isRef)(second)) {
|
|
160
|
-
const merged = (0, isEmpty_js_1.isEmpty)(second) ? first :
|
|
219
|
+
const merged = (0, isEmpty_js_1.isEmpty)(second) ? first : (0, exports.mergeSchemasOrRefs)({ first: readRef(first), second, getRef, normalize, system });
|
|
161
220
|
return merged;
|
|
162
221
|
}
|
|
163
222
|
if (!(0, refFns_js_1.isRef)(first) && (0, refFns_js_1.isRef)(second)) {
|
|
164
|
-
const merged = (0, isEmpty_js_1.isEmpty)(first) ? second :
|
|
223
|
+
const merged = (0, isEmpty_js_1.isEmpty)(first) ? second : (0, exports.mergeSchemasOrRefs)({ first, second: readRef(second), getRef, normalize, system });
|
|
165
224
|
return merged;
|
|
166
225
|
}
|
|
167
226
|
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;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNullOnly = exports.mergeNullOnly = void 0;
|
|
4
4
|
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* `schema`, nullable: a copy, as `schema` may be a component that other
|
|
7
|
+
* references share (a target followed through its reference).
|
|
8
|
+
*/
|
|
9
|
+
const mergeNullOnly = (schema) => ({
|
|
10
|
+
...schema,
|
|
11
|
+
...(schema.enum && !schema.enum.includes(null) ? { enum: [...schema.enum, null] } : {}),
|
|
12
|
+
nullable: true
|
|
13
|
+
});
|
|
12
14
|
exports.mergeNullOnly = mergeNullOnly;
|
|
13
15
|
const isNullOnly = (schema) => {
|
|
14
16
|
const { type: _type, nullable, enum: enumValues, ...rest } = schema;
|
|
@@ -7,6 +7,28 @@ export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObjec
|
|
|
7
7
|
* it, so the merge holds no dialect rules of its own. Must be idempotent.
|
|
8
8
|
*/
|
|
9
9
|
export type NormalizeFn = (schema: OpenAPIV3.SchemaObject) => OpenAPIV3.SchemaObject;
|
|
10
|
+
/**
|
|
11
|
+
* The `system` settings as the merge reads them (`client.json#settings.system`),
|
|
12
|
+
* and the keywords a later `allOf` member replaced under `latestWins`, so
|
|
13
|
+
* the parser can name them in one warning for the schema.
|
|
14
|
+
*/
|
|
15
|
+
export type MergeSystem = {
|
|
16
|
+
/** `strict`: a contradiction between members fails the merge. `latestWins`: the later member's keyword wins. */
|
|
17
|
+
allOf: 'strict' | 'latestWins';
|
|
18
|
+
/** `unknown`: a member with `not` merges, its `not` carried as written. Left out: `strict`, which refuses it. */
|
|
19
|
+
not?: 'strict' | 'unknown';
|
|
20
|
+
/**
|
|
21
|
+
* `client.json` `system.allOf`, kept while the first pass over a cross
|
|
22
|
+
* product's pairs sets `allOf` to `strict`. A member's own `allOf` merges
|
|
23
|
+
* under this setting in every pass. Left out: `allOf` is the setting.
|
|
24
|
+
*/
|
|
25
|
+
setting?: 'strict' | 'latestWins';
|
|
26
|
+
replaced: Set<string>;
|
|
27
|
+
/** `unknown`: an `anyOf` of two or more members is any value, so it adds nothing to the merge. Left out: `union`. */
|
|
28
|
+
anyOf?: 'union' | 'unknown';
|
|
29
|
+
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
30
|
+
unknown?: Set<string>;
|
|
31
|
+
};
|
|
10
32
|
export type OneOfObject = {
|
|
11
33
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
12
34
|
} & OpenAPIV3.SchemaObject;
|
|
@@ -16,5 +38,20 @@ export type AnyOfObject = {
|
|
|
16
38
|
export type SchemaObject = OpenAPIV3.SchemaObject;
|
|
17
39
|
export type ReferenceObject = OpenAPIV3.ReferenceObject;
|
|
18
40
|
export type SchemaOrReference = SchemaObject | ReferenceObject;
|
|
41
|
+
/**
|
|
42
|
+
* Two schemas to merge, how to follow a reference and normalize a member, and
|
|
43
|
+
* the `system` settings: what each merge step takes.
|
|
44
|
+
*/
|
|
45
|
+
export type MergeArgs<Schema = SchemaOrReference> = {
|
|
46
|
+
first: Schema;
|
|
47
|
+
second: Schema;
|
|
48
|
+
getRef: GetRefFn;
|
|
49
|
+
normalize: NormalizeFn;
|
|
50
|
+
system: MergeSystem;
|
|
51
|
+
};
|
|
52
|
+
/** {@link MergeArgs}, and the valibot schema `default`, `enum` and `example` values must pass. */
|
|
53
|
+
export type GenericMergeArgs<T> = MergeArgs<SchemaObject> & {
|
|
54
|
+
typeCheck?: v.GenericSchema<T>;
|
|
55
|
+
};
|
|
19
56
|
export type ArraySchemaObject = OpenAPIV3.ArraySchemaObject;
|
|
20
57
|
export declare const IntegerSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, "The number must be an integer.">]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { SiblingKeywords } from '../../../oas/schema/siblings.js';
|
|
2
3
|
import type { OasRefData } from '../../../oas/ref/ref-types.js';
|
|
3
4
|
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
4
5
|
import { OasRef } from '../../../oas/ref/Ref.js';
|
|
@@ -14,6 +15,11 @@ type ToRefV31Args<T extends OasRefData['refType']> = {
|
|
|
14
15
|
* reference; omitted everywhere else (a plain `$ref` is non-nullable).
|
|
15
16
|
*/
|
|
16
17
|
nullable?: boolean;
|
|
18
|
+
/** Use-site `readOnly` and `writeOnly` (see `RefFields.readOnly`): from a one-member `allOf`. */
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
writeOnly?: boolean;
|
|
21
|
+
/** The other keywords next to the reference in a one-member `allOf`, for `RefFields` (see `SiblingKeywords`). */
|
|
22
|
+
siblings?: SiblingKeywords;
|
|
17
23
|
};
|
|
18
|
-
export declare const toRefV31: <T extends OasRefData["refType"]>({ ref, refType, stackTrail, context, nullable }: ToRefV31Args<T>) => OasRef<T>;
|
|
24
|
+
export declare const toRefV31: <T extends OasRefData["refType"]>({ ref, refType, stackTrail, context, nullable, readOnly, writeOnly, siblings }: ToRefV31Args<T>) => OasRef<T>;
|
|
19
25
|
export {};
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toRefV31 = void 0;
|
|
4
4
|
const Ref_js_1 = require("../../../oas/ref/Ref.js");
|
|
5
5
|
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
6
|
-
const toRefV31 = ({ ref, refType, stackTrail, context, nullable }) => {
|
|
6
|
+
const toRefV31 = ({ ref, refType, stackTrail, context, nullable, readOnly, writeOnly, siblings }) => {
|
|
7
7
|
const { $ref, ...skipped } = ref;
|
|
8
8
|
if (!(0, isEmpty_js_1.isEmpty)(skipped)) {
|
|
9
9
|
context.logSkippedFields({ skipped, parent: ref, parentType: 'ref', stackTrail });
|
|
10
10
|
}
|
|
11
11
|
context.registerRef(stackTrail.clone(), $ref);
|
|
12
|
-
return context.withStackTrail(stackTrail, () => new Ref_js_1.OasRef({ refType, $ref, nullable }, context));
|
|
12
|
+
return context.withStackTrail(stackTrail, () => new Ref_js_1.OasRef({ ...siblings, refType, $ref, nullable, readOnly, writeOnly }, context));
|
|
13
13
|
};
|
|
14
14
|
exports.toRefV31 = toRefV31;
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toOptionalSchemaV3 = exports.toSchemaV3 = exports.toOptionalSchemasV3 = exports.toSchemasV3 = void 0;
|
|
4
4
|
const toRefV31_js_1 = require("../ref/toRefV31.js");
|
|
5
5
|
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
6
|
+
const isEmpty_js_1 = require("../../../helpers/isEmpty.js");
|
|
7
|
+
const Unknown_js_1 = require("../../../oas/unknown/Unknown.js");
|
|
6
8
|
const toArray_js_1 = require("../array/toArray.js");
|
|
7
9
|
const toObject_js_1 = require("../object/toObject.js");
|
|
8
10
|
const toInteger_js_1 = require("../integer/toInteger.js");
|
|
@@ -12,8 +14,13 @@ const toString_js_1 = require("../string/toString.js");
|
|
|
12
14
|
const toUnknown_js_1 = require("../unknown/toUnknown.js");
|
|
13
15
|
const toUnion_js_1 = require("../union/toUnion.js");
|
|
14
16
|
const refFns_js_2 = require("../../../helpers/refFns.js");
|
|
17
|
+
const toSiblingKeywords_js_1 = require("../../toSiblingKeywords.js");
|
|
18
|
+
const allOfSystem_js_1 = require("../../allOfSystem.js");
|
|
19
|
+
const anyOfSystem_js_1 = require("../../anyOfSystem.js");
|
|
20
|
+
const toAdditionalPropertiesV3_js_1 = require("../object/toAdditionalPropertiesV3.js");
|
|
15
21
|
const merge_intersection_js_1 = require("../_merge-all-of/merge-intersection.js");
|
|
16
22
|
const merge_union_js_1 = require("../_merge-all-of/merge-union.js");
|
|
23
|
+
const nullable_merge_js_1 = require("../_merge-all-of/nullable-merge.js");
|
|
17
24
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
18
25
|
const normalize_schema_shape_js_1 = require("./normalize-schema-shape.js");
|
|
19
26
|
const toSchemasV3 = ({ schemas, stackTrail, context }) => {
|
|
@@ -62,13 +69,15 @@ const withoutWrapperUnevaluatedProperties = ({ schema, parentType, stackTrail, c
|
|
|
62
69
|
return rest;
|
|
63
70
|
};
|
|
64
71
|
/**
|
|
65
|
-
* Is this a
|
|
72
|
+
* Is this a null-only schema member: 3.1's `type: 'null'` or `['null']`, or
|
|
73
|
+
* 3.0's `{ nullable: true, enum: [null] }`?
|
|
66
74
|
*/
|
|
67
75
|
const isNullTypeSchema = (member) => {
|
|
68
76
|
if ((0, refFns_js_1.isRef)(member)) {
|
|
69
77
|
return false;
|
|
70
78
|
}
|
|
71
|
-
|
|
79
|
+
// 3.0's way to write null too: `{ nullable: true, enum: [null] }`, as the 3.0 parser reads it.
|
|
80
|
+
return (0, normalize_schema_shape_js_1.isNullOnlyType)(member.type) || (0, nullable_merge_js_1.isNullOnly)(member);
|
|
72
81
|
};
|
|
73
82
|
/**
|
|
74
83
|
* Split `oneOf`/`anyOf` members into the non-null members plus whether a
|
|
@@ -114,15 +123,48 @@ const collapseSingleMember = (value, member) => {
|
|
|
114
123
|
};
|
|
115
124
|
const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
116
125
|
if ((0, refFns_js_1.isRef)(schema)) {
|
|
117
|
-
|
|
126
|
+
// In 3.1, as in JSON Schema 2020-12, keywords beside `$ref` apply with
|
|
127
|
+
// the target: the same as an `allOf` that starts with the reference.
|
|
128
|
+
const { $ref, ...keywords } = schema;
|
|
129
|
+
const allOf = 'allOf' in keywords ? keywords.allOf : undefined;
|
|
130
|
+
// An `allOf` that is not an array holds no members: reported, and the reference kept.
|
|
131
|
+
if (allOf !== undefined && !Array.isArray(allOf)) {
|
|
132
|
+
context.logSkippedFields({
|
|
133
|
+
skipped: { allOf },
|
|
134
|
+
parent: schema,
|
|
135
|
+
parentType: 'ref',
|
|
136
|
+
stackTrail
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const members = Array.isArray(allOf) ? allOf : [];
|
|
140
|
+
return Object.keys(keywords).length > 0
|
|
141
|
+
? (0, exports.toSchemaV3)({ schema: { ...keywords, allOf: [{ $ref }, ...members] }, stackTrail, context })
|
|
142
|
+
: (0, toRefV31_js_1.toRefV31)({ ref: schema, refType: 'schema', stackTrail, context });
|
|
118
143
|
}
|
|
119
144
|
// OpenAPI `not` has no faithful TypeScript representation: a generated type
|
|
120
145
|
// that ignored it would *widen* the contract (accepting shapes the schema
|
|
121
|
-
// forbids).
|
|
122
|
-
// is
|
|
123
|
-
//
|
|
146
|
+
// forbids). Under `client.json` `system.not: strict` (the default) the schema
|
|
147
|
+
// is refused rather than emit a type that lies. The throw is isolated by
|
|
148
|
+
// `tryParseAt` into an `INVALID_SCHEMA` issue, and consumers of this schema
|
|
149
|
+
// are pruned via `removeErroredItems` (INVALID_DEPENDENCY_REF).
|
|
150
|
+
//
|
|
151
|
+
// Under `system.not: unknown` the schema parses with its other keywords, and
|
|
152
|
+
// its `not` is kept as an `OasUnknown` that core does not read: a generator
|
|
153
|
+
// can see that the document says "not something".
|
|
124
154
|
if ('not' in schema) {
|
|
125
|
-
|
|
155
|
+
// A test's mock context may have no `system`.
|
|
156
|
+
if (context.system?.not !== 'unknown') {
|
|
157
|
+
throw new Error('Schema uses unsupported "not" keyword');
|
|
158
|
+
}
|
|
159
|
+
const { not: _not, ...keywords } = schema;
|
|
160
|
+
const parsed = (0, exports.toSchemaV3)({ schema: keywords, stackTrail, context });
|
|
161
|
+
// Only a one-member `allOf` of a `$ref` parses to a reference, and a
|
|
162
|
+
// reference has no field for a `not`. Fail rather than lose it.
|
|
163
|
+
if (parsed.isRef()) {
|
|
164
|
+
throw new Error('Schema uses "not" next to a one-member allOf reference, which cannot keep it');
|
|
165
|
+
}
|
|
166
|
+
parsed.not = stackTrail.trace('not', notTrail => context.withStackTrail(notTrail, () => new Unknown_js_1.OasUnknown({}, context)));
|
|
167
|
+
return parsed;
|
|
126
168
|
}
|
|
127
169
|
const normalized = (0, normalize_schema_shape_js_1.normalizeSchemaShape)(schema);
|
|
128
170
|
if (normalized !== schema) {
|
|
@@ -148,14 +190,40 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
148
190
|
const members = allOf ?? [];
|
|
149
191
|
if (members.length === 1) {
|
|
150
192
|
const [member] = members;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
193
|
+
// Keywords next to the one member say how this site uses the
|
|
194
|
+
// reference, which stays lazy, so a self-reference still ends:
|
|
195
|
+
// `nullable`, `readOnly` and `writeOnly` ride it as use-site flags,
|
|
196
|
+
// and the others are read without the target's type (`siblings`).
|
|
197
|
+
// `resolve()` applies them to a copy of the target at generate time;
|
|
198
|
+
// the ones its type cannot take are left out there. The shared model
|
|
199
|
+
// never changes.
|
|
200
|
+
if ((0, refFns_js_1.isRef)(member)) {
|
|
201
|
+
const { nullable, readOnly, writeOnly, ...keywords } = value;
|
|
202
|
+
const siblings = (0, isEmpty_js_1.isEmpty)(keywords)
|
|
203
|
+
? undefined
|
|
204
|
+
: (0, toSiblingKeywords_js_1.toSiblingKeywords)({
|
|
205
|
+
keywords,
|
|
206
|
+
properties: stackTrail.trace('properties', propertiesTrail => (0, exports.toOptionalSchemasV3)({ schemas: keywords.properties, stackTrail: propertiesTrail, context })),
|
|
207
|
+
additionalProperties: stackTrail.trace('additionalProperties', additionalTrail => (0, toAdditionalPropertiesV3_js_1.toAdditionalPropertiesV3)({
|
|
208
|
+
additionalProperties: keywords.additionalProperties,
|
|
209
|
+
stackTrail: additionalTrail,
|
|
210
|
+
context
|
|
211
|
+
})),
|
|
212
|
+
stackTrail,
|
|
213
|
+
context
|
|
214
|
+
});
|
|
215
|
+
if (nullable || readOnly || writeOnly || siblings) {
|
|
216
|
+
return (0, toRefV31_js_1.toRefV31)({
|
|
217
|
+
ref: member,
|
|
218
|
+
refType: 'schema',
|
|
219
|
+
nullable: nullable || undefined,
|
|
220
|
+
readOnly: readOnly || undefined,
|
|
221
|
+
writeOnly: writeOnly || undefined,
|
|
222
|
+
siblings,
|
|
223
|
+
stackTrail: st,
|
|
224
|
+
context
|
|
225
|
+
});
|
|
226
|
+
}
|
|
159
227
|
}
|
|
160
228
|
return (0, exports.toSchemaV3)({
|
|
161
229
|
schema: collapseSingleMember(value, member),
|
|
@@ -163,11 +231,15 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
163
231
|
context
|
|
164
232
|
});
|
|
165
233
|
}
|
|
234
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
166
235
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
167
236
|
schema: wrapper,
|
|
168
237
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
169
|
-
normalize: normalize_schema_shape_js_1.normalizeMergeMember
|
|
238
|
+
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
239
|
+
system
|
|
170
240
|
});
|
|
241
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
242
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
171
243
|
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
172
244
|
});
|
|
173
245
|
}
|
|
@@ -191,12 +263,16 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
191
263
|
const withoutNull = hasNullMember
|
|
192
264
|
? { ...wrapper, oneOf: oneOfWithoutNull, nullable: true }
|
|
193
265
|
: wrapper;
|
|
266
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
194
267
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
195
268
|
schema: withoutNull,
|
|
196
269
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
197
270
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
271
|
+
system,
|
|
198
272
|
groupType: 'oneOf'
|
|
199
273
|
});
|
|
274
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
275
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
200
276
|
if (!('oneOf' in merged) || !Array.isArray(merged.oneOf)) {
|
|
201
277
|
throw new Error('Missing "oneOf" array');
|
|
202
278
|
}
|
|
@@ -240,6 +316,21 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
240
316
|
stackTrail,
|
|
241
317
|
context
|
|
242
318
|
});
|
|
319
|
+
// Under `system.anyOf: unknown`, as Cloudflare's `cf` reads it, an `anyOf`
|
|
320
|
+
// of two or more members is any value: the schema parses with its other
|
|
321
|
+
// keywords, so the properties next to it stay, without the members.
|
|
322
|
+
if ((0, anyOfSystem_js_1.isUnknownAnyOf)({ members: wrapper.anyOf ?? [], setting: context.system?.anyOf, getRef: (0, refFns_js_2.toGetRef)(context.documentObject) })) {
|
|
323
|
+
(0, anyOfSystem_js_1.logUnknownAnyOf)({ stackTrail, parent: schema, context });
|
|
324
|
+
const keywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({
|
|
325
|
+
schema: wrapper,
|
|
326
|
+
setting: context.system?.anyOf,
|
|
327
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject)
|
|
328
|
+
});
|
|
329
|
+
// A `default` alone is no type: the parser would guess one from it.
|
|
330
|
+
return (0, anyOfSystem_js_1.hasShapeKeyword)(keywords)
|
|
331
|
+
? (0, exports.toSchemaV3)({ schema: keywords, stackTrail, context })
|
|
332
|
+
: (0, toUnknown_js_1.toUnknown)({ value: keywords, stackTrail, context });
|
|
333
|
+
}
|
|
243
334
|
return stackTrail.trace('anyOf', st => {
|
|
244
335
|
// deno-lint-ignore ban-ts-comment
|
|
245
336
|
// @ts-expect-error
|
|
@@ -253,12 +344,16 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
253
344
|
const withoutNull = hasNullMember
|
|
254
345
|
? { ...wrapper, anyOf: anyOfWithoutNull, nullable: true }
|
|
255
346
|
: wrapper;
|
|
347
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
256
348
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
257
349
|
schema: withoutNull,
|
|
258
350
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
259
351
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
352
|
+
system,
|
|
260
353
|
groupType: 'anyOf'
|
|
261
354
|
});
|
|
355
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
356
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
262
357
|
if (!('anyOf' in merged) || !Array.isArray(merged.anyOf)) {
|
|
263
358
|
throw new Error('Missing "anyOf" array');
|
|
264
359
|
}
|
|
@@ -9,6 +9,12 @@ type DecomposeUnionReturn = {
|
|
|
9
9
|
afterExcluded: SchemaObject;
|
|
10
10
|
};
|
|
11
11
|
export declare const decomposeUnion: ({ schema, groupType }: DecomposeUnionArgs) => DecomposeUnionReturn;
|
|
12
|
-
/**
|
|
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
|
+
*/
|
|
13
19
|
export declare const isUnionLevelKey: (key: string) => boolean;
|
|
14
20
|
export {};
|
|
@@ -60,8 +60,14 @@ const excludedProperties = [
|
|
|
60
60
|
'writeOnly',
|
|
61
61
|
'deprecated'
|
|
62
62
|
];
|
|
63
|
-
/**
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Is `key` a union-level key, kept on the union rather than merged into each
|
|
65
|
+
* member? A specification extension (`x-…`) is one too: it says something
|
|
66
|
+
* about the union, as Fern's `x-fern-property-name` renames the property,
|
|
67
|
+
* and `toUnion` keeps it. Merged into each member, it was lost, and each
|
|
68
|
+
* `$ref` member was resolved to merge it.
|
|
69
|
+
*/
|
|
70
|
+
const isUnionLevelKey = (key) => excludedProperties.includes(key) || key.startsWith('x-');
|
|
65
71
|
exports.isUnionLevelKey = isUnionLevelKey;
|
|
66
72
|
const exclude = (entries) => {
|
|
67
73
|
return entries.reduce((acc, [key, value]) => {
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { SchemaObject,
|
|
2
|
-
|
|
3
|
-
export declare const genericMerge: <T>(first: SchemaObject, second: SchemaObject, getRef: GetRefFn, normalize: NormalizeFn, typeCheck?: v.GenericSchema<T>) => SchemaObject;
|
|
1
|
+
import type { SchemaObject, GenericMergeArgs } from './types.js';
|
|
2
|
+
export declare const genericMerge: <T>({ first, second, getRef, normalize, system, typeCheck }: GenericMergeArgs<T>) => SchemaObject;
|
|
@@ -4,11 +4,11 @@ exports.genericMerge = void 0;
|
|
|
4
4
|
const merge_enum_values_js_1 = require("./merge-enum-values.js");
|
|
5
5
|
const merge_properties_js_1 = require("./merge-properties.js");
|
|
6
6
|
const merge_required_js_1 = require("./merge-required.js");
|
|
7
|
-
const genericMerge = (first, second, getRef, normalize, typeCheck) => {
|
|
7
|
+
const genericMerge = ({ first, second, getRef, normalize, system, typeCheck }) => {
|
|
8
8
|
return {
|
|
9
9
|
...first,
|
|
10
10
|
...second,
|
|
11
|
-
...(0, merge_properties_js_1.mergeProperties)(first, second, getRef, normalize),
|
|
11
|
+
...(0, merge_properties_js_1.mergeProperties)({ first, second, getRef, normalize, system }),
|
|
12
12
|
...(0, merge_required_js_1.mergeRequired)(first, second),
|
|
13
13
|
...(0, merge_enum_values_js_1.mergeEnumValues)(first, second, typeCheck)
|
|
14
14
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { MergeArgs } from './types.js';
|
|
2
|
+
import type { ArraySchemaObject, SchemaObject } from './types.js';
|
|
3
|
+
export declare function mergeArrayConstraints({ first, second, getRef, normalize, system }: MergeArgs<ArraySchemaObject | SchemaObject>): SchemaObject;
|
|
@@ -38,10 +38,10 @@ const merge_js_1 = require("./merge.js");
|
|
|
38
38
|
const generic_merge_js_1 = require("./generic-merge.js");
|
|
39
39
|
const v = __importStar(require("valibot"));
|
|
40
40
|
const check_type_conflicts_js_1 = require("./check-type-conflicts.js");
|
|
41
|
-
function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
41
|
+
function mergeArrayConstraints({ first, second, getRef, normalize, system }) {
|
|
42
42
|
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
43
|
-
const merged = (0, generic_merge_js_1.genericMerge)(first, second, getRef, normalize, v.array(v.any()));
|
|
44
|
-
const items = mergeItems(first, second, getRef, normalize);
|
|
43
|
+
const merged = (0, generic_merge_js_1.genericMerge)({ first, second, getRef, normalize, system, typeCheck: v.array(v.any()) });
|
|
44
|
+
const items = mergeItems({ first, second, getRef, normalize, system });
|
|
45
45
|
// With no `items` on either side, `items` stays absent (unknown items).
|
|
46
46
|
const result = items === undefined ? merged : { ...merged, type: 'array', items };
|
|
47
47
|
// Merge minItems
|
|
@@ -62,9 +62,9 @@ function mergeArrayConstraints(first, second, getRef, normalize) {
|
|
|
62
62
|
}
|
|
63
63
|
return result;
|
|
64
64
|
}
|
|
65
|
-
const mergeItems = (first, second, getRef, normalize) => {
|
|
65
|
+
const mergeItems = ({ first, second, getRef, normalize, system }) => {
|
|
66
66
|
if ('items' in first && 'items' in second && first.items && second.items) {
|
|
67
|
-
return (0, merge_js_1.mergeSchemasOrRefs)(first.items, second.items, getRef, normalize);
|
|
67
|
+
return (0, merge_js_1.mergeSchemasOrRefs)({ first: first.items, second: second.items, getRef, normalize, system });
|
|
68
68
|
}
|
|
69
69
|
if ('items' in first && first.items) {
|
|
70
70
|
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, normalize, system }: MergeArgs<OpenAPIV3.SchemaObject>): OpenAPIV3.SchemaObject;
|