@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
import { traverseSchema } from '../schemaPath/traverseSchema.js';
|
|
3
|
+
import { toSiblingAnnotations } from '../schema/siblings.js';
|
|
3
4
|
import { OasBase } from '../../types/OasBase.js';
|
|
4
5
|
/**
|
|
5
6
|
* Object representing an unknown type in the OpenAPI Specification.
|
|
@@ -69,6 +70,17 @@ export class OasUnknown extends OasBase {
|
|
|
69
70
|
writable: true,
|
|
70
71
|
value: void 0
|
|
71
72
|
});
|
|
73
|
+
/**
|
|
74
|
+
* The schema's `not`, kept as an `OasUnknown` under `client.json`
|
|
75
|
+
* `system.not: unknown`: the document says "not something", and core does
|
|
76
|
+
* not read what. `undefined` otherwise.
|
|
77
|
+
*/
|
|
78
|
+
Object.defineProperty(this, "not", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: undefined
|
|
83
|
+
});
|
|
72
84
|
this.title = fields.title;
|
|
73
85
|
this.description = fields.description;
|
|
74
86
|
this.extensionFields = fields.extensionFields;
|
|
@@ -78,6 +90,32 @@ export class OasUnknown extends OasBase {
|
|
|
78
90
|
isRef() {
|
|
79
91
|
return false;
|
|
80
92
|
}
|
|
93
|
+
/** Always `false`: this schema has no `readOnly`. */
|
|
94
|
+
isReadOnly() {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
/** Always `false`: this schema has no `writeOnly`. */
|
|
98
|
+
isWriteOnly() {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A copy of this schema with what `ref` adds at its site applied: its
|
|
103
|
+
* `nullable` and the keywords next to it (`SiblingKeywords`) that
|
|
104
|
+
* this type takes, a sibling's value winning. A value that does not fit
|
|
105
|
+
* this type is left out (the parser reports it). For `OasRef.resolve()`.
|
|
106
|
+
* This schema does not change, and the copy shares its child schemas.
|
|
107
|
+
*/
|
|
108
|
+
clone(ref) {
|
|
109
|
+
const nullable = this.nullable || ref?.nullable || undefined;
|
|
110
|
+
const copy = new OasUnknown({
|
|
111
|
+
...toSiblingAnnotations(this, ref),
|
|
112
|
+
example: ref?.example ?? this.example,
|
|
113
|
+
nullable,
|
|
114
|
+
});
|
|
115
|
+
copy.stackTrail = this.stackTrail;
|
|
116
|
+
copy.not = this.not;
|
|
117
|
+
return copy;
|
|
118
|
+
}
|
|
81
119
|
traverse(path) {
|
|
82
120
|
return traverseSchema(this, path);
|
|
83
121
|
}
|
package/esm/oas/void/Void.d.ts
CHANGED
|
@@ -159,6 +159,10 @@ export declare class OasVoid extends OasBase {
|
|
|
159
159
|
constructor(fields?: VoidFields, context?: ParseContextType);
|
|
160
160
|
static empty(): OasVoid;
|
|
161
161
|
isRef(): this is OasRef<'schema'>;
|
|
162
|
+
/** Always `false`: this schema has no `readOnly`. */
|
|
163
|
+
isReadOnly(): boolean;
|
|
164
|
+
/** Always `false`: this schema has no `writeOnly`. */
|
|
165
|
+
isWriteOnly(): boolean;
|
|
162
166
|
resolve(): OasVoid;
|
|
163
167
|
resolveOnce(): OasVoid;
|
|
164
168
|
}
|
package/esm/oas/void/Void.js
CHANGED
|
@@ -176,6 +176,14 @@ export class OasVoid extends OasBase {
|
|
|
176
176
|
isRef() {
|
|
177
177
|
return false;
|
|
178
178
|
}
|
|
179
|
+
/** Always `false`: this schema has no `readOnly`. */
|
|
180
|
+
isReadOnly() {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
/** Always `false`: this schema has no `writeOnly`. */
|
|
184
|
+
isWriteOnly() {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
179
187
|
resolve() {
|
|
180
188
|
return this;
|
|
181
189
|
}
|
|
@@ -122,8 +122,8 @@ export declare class OasWebhook extends OasBase {
|
|
|
122
122
|
/**
|
|
123
123
|
* Resolve the inbound parameters (e.g. the signature/headers a handler
|
|
124
124
|
* receives), optionally filtered by location. Mirrors
|
|
125
|
-
* {@link OasOperation.toParams}
|
|
126
|
-
* their direction is inbound.
|
|
125
|
+
* {@link OasOperation.toParams}, path item parameters included; the
|
|
126
|
+
* parameters carry the same shape, only their direction is inbound.
|
|
127
127
|
*/
|
|
128
128
|
toParams(filter?: OasParameterLocation[]): OasParameter[];
|
|
129
129
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
import { toPrimaryResponseCode } from '../response/toPrimaryResponseCode.js';
|
|
3
3
|
import { OasBase } from '../../types/OasBase.js';
|
|
4
|
+
import { toEffectiveParameters } from '../operation/toEffectiveParameters.js';
|
|
4
5
|
/**
|
|
5
6
|
* Represents an OpenAPI 3.1 webhook — a third OAS subject, peer to
|
|
6
7
|
* {@link OasOperation} and the schema/model subjects.
|
|
@@ -168,13 +169,13 @@ export class OasWebhook extends OasBase {
|
|
|
168
169
|
/**
|
|
169
170
|
* Resolve the inbound parameters (e.g. the signature/headers a handler
|
|
170
171
|
* receives), optionally filtered by location. Mirrors
|
|
171
|
-
* {@link OasOperation.toParams}
|
|
172
|
-
* their direction is inbound.
|
|
172
|
+
* {@link OasOperation.toParams}, path item parameters included; the
|
|
173
|
+
* parameters carry the same shape, only their direction is inbound.
|
|
173
174
|
*/
|
|
174
175
|
toParams(filter) {
|
|
175
|
-
return (this.parameters
|
|
176
|
-
|
|
177
|
-
.filter(param => (filter?.length ? filter.includes(param.location) : true))
|
|
176
|
+
return toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })
|
|
177
|
+
.map(param => param.resolve())
|
|
178
|
+
.filter(param => (filter?.length ? filter.includes(param.location) : true));
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
181
|
* The status code of the primary acknowledgement response — the lowest 2xx
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
2
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
3
|
+
/** What the `allOf` merge reads of `client.json#settings.system`, and what it reports back. */
|
|
4
|
+
type AllOfSystem = {
|
|
5
|
+
allOf: 'strict' | 'latestWins';
|
|
6
|
+
not: 'strict' | 'unknown';
|
|
7
|
+
anyOf: 'union' | 'unknown';
|
|
8
|
+
/** The keywords a later member replaced under `latestWins`. */
|
|
9
|
+
replaced: Set<string>;
|
|
10
|
+
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
11
|
+
unknown: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The `system` settings for one merge: the `allOf` mode, `strict` when the
|
|
15
|
+
* settings leave it out, and an empty set for the keywords a later member
|
|
16
|
+
* replaces. Shared by the 3.0, 3.1 and 3.2 parsers.
|
|
17
|
+
*/
|
|
18
|
+
export declare const toAllOfSystem: (context: ParseContextType) => AllOfSystem;
|
|
19
|
+
type LogAllOfContradictionsArgs = {
|
|
20
|
+
system: AllOfSystem;
|
|
21
|
+
/** The trail of the schema whose members were merged. */
|
|
22
|
+
stackTrail: StackTrail;
|
|
23
|
+
parent: unknown;
|
|
24
|
+
context: ParseContextType;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One warning for a schema whose `allOf` members contradicted, naming the
|
|
28
|
+
* keywords the later member kept (`system.allOf: latestWins`). Nothing when
|
|
29
|
+
* no keyword was replaced.
|
|
30
|
+
*/
|
|
31
|
+
export declare const logAllOfContradictions: ({ system, stackTrail, parent, context }: LogAllOfContradictionsArgs) => void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `system` settings for one merge: the `allOf` mode, `strict` when the
|
|
3
|
+
* settings leave it out, and an empty set for the keywords a later member
|
|
4
|
+
* replaces. Shared by the 3.0, 3.1 and 3.2 parsers.
|
|
5
|
+
*/
|
|
6
|
+
export const toAllOfSystem = (context) => ({
|
|
7
|
+
// A test's mock context may have no `system`.
|
|
8
|
+
allOf: context.system?.allOf ?? 'strict',
|
|
9
|
+
not: context.system?.not ?? 'strict',
|
|
10
|
+
anyOf: context.system?.anyOf ?? 'union',
|
|
11
|
+
replaced: new Set(),
|
|
12
|
+
unknown: new Set()
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* One warning for a schema whose `allOf` members contradicted, naming the
|
|
16
|
+
* keywords the later member kept (`system.allOf: latestWins`). Nothing when
|
|
17
|
+
* no keyword was replaced.
|
|
18
|
+
*/
|
|
19
|
+
export const logAllOfContradictions = ({ system, stackTrail, parent, context }) => {
|
|
20
|
+
if (system.replaced.size === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
context.logIssueNoKey({
|
|
24
|
+
level: 'warning',
|
|
25
|
+
message: `The allOf members contradict on ${[...system.replaced].join(', ')}; the later member's values are kept (system.allOf is latestWins).`,
|
|
26
|
+
parent,
|
|
27
|
+
stackTrail,
|
|
28
|
+
type: 'ALLOF_CONTRADICTION'
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
3
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
4
|
+
/** Whether one of the members of an `anyOf` is only `null`. */
|
|
5
|
+
export declare const hasNullMember: (members: readonly object[]) => boolean;
|
|
6
|
+
/** Follows a reference to the schema it names, as the parsers' `GetRefFn` does. */
|
|
7
|
+
type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
8
|
+
/** Arguments for {@link isUnknownAnyOf}. */
|
|
9
|
+
type IsUnknownAnyOfArgs = {
|
|
10
|
+
/** The `anyOf` members, as the document writes them. */
|
|
11
|
+
members: readonly (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
12
|
+
/** `client.json` `system.anyOf`. A test's mock context may have none. */
|
|
13
|
+
setting: 'union' | 'unknown' | undefined;
|
|
14
|
+
getRef: GetRefFn;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Whether `system.anyOf: unknown` reads an `anyOf` as any value, as
|
|
18
|
+
* Cloudflare's `cf` reads it: when it has two or more members, not counting a
|
|
19
|
+
* `null` one, and one of them is not a single value.
|
|
20
|
+
*
|
|
21
|
+
* - An `anyOf` with one member is read as before, so `anyOf: [{ $ref }, {
|
|
22
|
+
* type: 'null' }]` stays a nullable reference.
|
|
23
|
+
* - An `anyOf` of single values stays a union (`string | number`): cf gives
|
|
24
|
+
* it one flag.
|
|
25
|
+
*/
|
|
26
|
+
export declare const isUnknownAnyOf: ({ members, setting, getRef }: IsUnknownAnyOfArgs) => boolean;
|
|
27
|
+
/** Arguments for {@link withoutUnknownAnyOf}. */
|
|
28
|
+
type WithoutUnknownAnyOfArgs = {
|
|
29
|
+
schema: OpenAPIV3.SchemaObject;
|
|
30
|
+
/** `client.json` `system.anyOf`. */
|
|
31
|
+
setting: 'union' | 'unknown' | undefined;
|
|
32
|
+
getRef: GetRefFn;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* `schema` with its other keywords and without an `anyOf` that
|
|
36
|
+
* `system.anyOf: unknown` reads as any value ({@link isUnknownAnyOf}), so the
|
|
37
|
+
* properties next to the `anyOf` stay. A `null` member makes it nullable. Any
|
|
38
|
+
* other schema is returned as it is.
|
|
39
|
+
*/
|
|
40
|
+
export declare const withoutUnknownAnyOf: ({ schema, setting, getRef }: WithoutUnknownAnyOfArgs) => OpenAPIV3.SchemaObject;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the keywords that are left when an `anyOf` is read as any value
|
|
43
|
+
* ({@link withoutUnknownAnyOf}) give the schema a shape of its own:
|
|
44
|
+
* `properties` next to the `anyOf` do. A `default`, an `example` or a
|
|
45
|
+
* `format` alone does not. The parser must not guess a type from them, as it
|
|
46
|
+
* does for a schema that has no type (`MISSING_STRING_TYPE`): the members
|
|
47
|
+
* were the type, and they are gone.
|
|
48
|
+
*/
|
|
49
|
+
export declare const hasShapeKeyword: (schema: object) => boolean;
|
|
50
|
+
/** Arguments for {@link logUnknownAnyOf}. */
|
|
51
|
+
type LogUnknownAnyOfArgs = {
|
|
52
|
+
/** The trail of the schema whose `anyOf` was read as any value. */
|
|
53
|
+
stackTrail: StackTrail;
|
|
54
|
+
parent: unknown;
|
|
55
|
+
context: ParseContextType;
|
|
56
|
+
};
|
|
57
|
+
/** Arguments for {@link logMergedUnknownAnyOf}. */
|
|
58
|
+
type LogMergedUnknownAnyOfArgs = LogUnknownAnyOfArgs & {
|
|
59
|
+
/** The merge's `system`: `unknown` holds `anyOf` when the merge read one as any value. */
|
|
60
|
+
system: {
|
|
61
|
+
unknown: Set<string>;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** One warning for a schema whose merge read an `anyOf` as any value. Nothing when it read none. */
|
|
65
|
+
export declare const logMergedUnknownAnyOf: ({ system, stackTrail, parent, context }: LogMergedUnknownAnyOfArgs) => void;
|
|
66
|
+
/** One warning for a schema whose `anyOf` was read as any value (`system.anyOf: unknown`). */
|
|
67
|
+
export declare const logUnknownAnyOf: ({ stackTrail, parent, context }: LogUnknownAnyOfArgs) => void;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { isNullOnlyType } from './v3-2/schema/normalize-schema-shape.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether an `anyOf` member is only `null`: 3.0's `{ nullable: true, enum:
|
|
4
|
+
* [null] }`, or 3.1's `{ type: 'null' }` or `{ type: ['null'] }`, as the
|
|
5
|
+
* parsers read a null member.
|
|
6
|
+
*/
|
|
7
|
+
const isNullMember = (member) => {
|
|
8
|
+
const fields = Object.fromEntries(Object.entries(member));
|
|
9
|
+
const values = fields.enum;
|
|
10
|
+
return (isNullOnlyType(fields.type) ||
|
|
11
|
+
(fields.nullable === true && Array.isArray(values) && values.length === 1 && values[0] === null));
|
|
12
|
+
};
|
|
13
|
+
/** Whether one of the members of an `anyOf` is only `null`. */
|
|
14
|
+
export const hasNullMember = (members) => members.some(isNullMember);
|
|
15
|
+
/** The types of a single value: a member of one of them is a scalar. */
|
|
16
|
+
const SCALAR_TYPES = ['string', 'number', 'integer', 'boolean'];
|
|
17
|
+
/** The JavaScript types of a scalar enum value. */
|
|
18
|
+
const SCALAR_VALUE_TYPES = ['string', 'number', 'boolean'];
|
|
19
|
+
/**
|
|
20
|
+
* Whether an `anyOf` member, followed through its references, is a single
|
|
21
|
+
* value: its `type` is a string, number, integer or boolean (besides `null`),
|
|
22
|
+
* or it has no `type` and an `enum` of such values.
|
|
23
|
+
*/
|
|
24
|
+
const isScalarMember = (member) => {
|
|
25
|
+
const fields = Object.fromEntries(Object.entries(member));
|
|
26
|
+
const types = Array.isArray(fields.type) ? fields.type.filter(type => type !== 'null') : [fields.type];
|
|
27
|
+
if (fields.type !== undefined) {
|
|
28
|
+
return types.length > 0 && types.every(type => SCALAR_TYPES.includes(type));
|
|
29
|
+
}
|
|
30
|
+
return (Array.isArray(fields.enum) &&
|
|
31
|
+
fields.enum.every(value => value === null || SCALAR_VALUE_TYPES.includes(typeof value)));
|
|
32
|
+
};
|
|
33
|
+
/** Follows a member through its references, to the schema it names. Stops after 10 steps, at a cycle. */
|
|
34
|
+
const toMemberSchema = (member, getRef, steps = 0) => {
|
|
35
|
+
if (!('$ref' in member)) {
|
|
36
|
+
return member;
|
|
37
|
+
}
|
|
38
|
+
return steps < 10 ? toMemberSchema(getRef(member), getRef, steps + 1) : undefined;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Whether `system.anyOf: unknown` reads an `anyOf` as any value, as
|
|
42
|
+
* Cloudflare's `cf` reads it: when it has two or more members, not counting a
|
|
43
|
+
* `null` one, and one of them is not a single value.
|
|
44
|
+
*
|
|
45
|
+
* - An `anyOf` with one member is read as before, so `anyOf: [{ $ref }, {
|
|
46
|
+
* type: 'null' }]` stays a nullable reference.
|
|
47
|
+
* - An `anyOf` of single values stays a union (`string | number`): cf gives
|
|
48
|
+
* it one flag.
|
|
49
|
+
*/
|
|
50
|
+
export const isUnknownAnyOf = ({ members, setting, getRef }) => {
|
|
51
|
+
if (setting !== 'unknown') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const values = members.filter(member => !isNullMember(member)).map(member => toMemberSchema(member, getRef));
|
|
55
|
+
return values.length > 1 && !values.every(value => value !== undefined && isScalarMember(value));
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* `schema` with its other keywords and without an `anyOf` that
|
|
59
|
+
* `system.anyOf: unknown` reads as any value ({@link isUnknownAnyOf}), so the
|
|
60
|
+
* properties next to the `anyOf` stay. A `null` member makes it nullable. Any
|
|
61
|
+
* other schema is returned as it is.
|
|
62
|
+
*/
|
|
63
|
+
export const withoutUnknownAnyOf = ({ schema, setting, getRef }) => {
|
|
64
|
+
const members = schema.anyOf ?? [];
|
|
65
|
+
if (!isUnknownAnyOf({ members, setting, getRef })) {
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
const { anyOf: _anyOf, ...keywords } = schema;
|
|
69
|
+
return hasNullMember(members) ? { ...keywords, nullable: true } : keywords;
|
|
70
|
+
};
|
|
71
|
+
/** The keywords that give a schema its own shape, so it is more than any value. */
|
|
72
|
+
const SHAPE_KEYWORDS = [
|
|
73
|
+
'type',
|
|
74
|
+
'properties',
|
|
75
|
+
'additionalProperties',
|
|
76
|
+
'items',
|
|
77
|
+
'enum',
|
|
78
|
+
'const',
|
|
79
|
+
'allOf',
|
|
80
|
+
'oneOf',
|
|
81
|
+
'$ref'
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Whether the keywords that are left when an `anyOf` is read as any value
|
|
85
|
+
* ({@link withoutUnknownAnyOf}) give the schema a shape of its own:
|
|
86
|
+
* `properties` next to the `anyOf` do. A `default`, an `example` or a
|
|
87
|
+
* `format` alone does not. The parser must not guess a type from them, as it
|
|
88
|
+
* does for a schema that has no type (`MISSING_STRING_TYPE`): the members
|
|
89
|
+
* were the type, and they are gone.
|
|
90
|
+
*/
|
|
91
|
+
export const hasShapeKeyword = (schema) => SHAPE_KEYWORDS.some(keyword => keyword in schema);
|
|
92
|
+
/** One warning for a schema whose merge read an `anyOf` as any value. Nothing when it read none. */
|
|
93
|
+
export const logMergedUnknownAnyOf = ({ system, stackTrail, parent, context }) => {
|
|
94
|
+
if (system.unknown.has('anyOf')) {
|
|
95
|
+
logUnknownAnyOf({ stackTrail, parent, context });
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/** One warning for a schema whose `anyOf` was read as any value (`system.anyOf: unknown`). */
|
|
99
|
+
export const logUnknownAnyOf = ({ stackTrail, parent, context }) => {
|
|
100
|
+
context.logIssueNoKey({
|
|
101
|
+
level: 'warning',
|
|
102
|
+
message: 'The anyOf is read as any value (system.anyOf is unknown): the schema keeps its other keywords, without the anyOf members.',
|
|
103
|
+
parent,
|
|
104
|
+
stackTrail,
|
|
105
|
+
type: 'ANYOF_AS_UNKNOWN'
|
|
106
|
+
});
|
|
107
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import type { ParseContextType } from '../context/parseTypes.js';
|
|
3
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
4
|
+
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
5
|
+
import type { OasRef } from '../oas/ref/Ref.js';
|
|
6
|
+
import type { SiblingKeywords } from '../oas/schema/siblings.js';
|
|
7
|
+
type ToSiblingKeywordsArgs = {
|
|
8
|
+
/** The keywords next to the one member, without `allOf` and the use-site flags. */
|
|
9
|
+
keywords: OpenAPIV3.SchemaObject;
|
|
10
|
+
/** `keywords.properties`, parsed by the caller's version of the parser. */
|
|
11
|
+
properties: Record<string, OasSchema | OasRef<'schema'>> | undefined;
|
|
12
|
+
/** `keywords.additionalProperties`, parsed the same way. */
|
|
13
|
+
additionalProperties: boolean | OasSchema | OasRef<'schema'> | undefined;
|
|
14
|
+
/** The trail of the schema that holds the `allOf`. */
|
|
15
|
+
stackTrail: StackTrail;
|
|
16
|
+
context: ParseContextType;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The keywords next to a reference in a one-member `allOf`, read without the
|
|
20
|
+
* target's type (see `SiblingKeywords`): the reference stays lazy, so the
|
|
21
|
+
* target may not be parsed yet. The ones the target cannot take are left out
|
|
22
|
+
* at generate time (`OasRef.toSkippedSiblings`). An extension (`x-*`) is kept, as each
|
|
23
|
+
* version's `toSpecificationExtensionsV3` keeps one; a keyword that no schema
|
|
24
|
+
* has here is reported. `undefined` when no keyword is left. Shared by the
|
|
25
|
+
* 3.0, 3.1 and 3.2 parsers.
|
|
26
|
+
*/
|
|
27
|
+
export declare const toSiblingKeywords: ({ keywords, properties, additionalProperties, stackTrail, context }: ToSiblingKeywordsArgs) => SiblingKeywords | undefined;
|
|
28
|
+
export {};
|
|
@@ -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 {};
|