@skmtc/core 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/CoreContext.js +22 -8
- package/esm/context/GenerateContext.d.ts +6 -5
- package/esm/context/GenerateContext.js +112 -38
- package/esm/context/ParseContext.d.ts +18 -1
- package/esm/context/ParseContext.js +102 -3
- package/esm/context/generateTypes.d.ts +33 -4
- package/esm/context/generateTypes.js +4 -0
- package/esm/context/toGenerationFailure.d.ts +21 -0
- package/esm/context/toGenerationFailure.js +38 -0
- package/esm/context/tryParseAt.d.ts +4 -1
- package/esm/context/tryParseAt.js +10 -3
- package/esm/dsl/CustomValue.d.ts +4 -0
- package/esm/dsl/CustomValue.js +8 -0
- package/esm/dsl/Definition.d.ts +10 -0
- package/esm/dsl/Definition.js +14 -0
- package/esm/dsl/PendingDefinition.d.ts +47 -0
- package/esm/dsl/PendingDefinition.js +83 -0
- package/esm/dsl/model/ModelDriver.d.ts +55 -1
- package/esm/dsl/model/ModelDriver.js +228 -51
- package/esm/dsl/model/toModelEntry.d.ts +1 -1
- package/esm/dsl/model/toModelEntry.js +1 -1
- package/esm/dsl/model/types.d.ts +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/esm/dsl/webhook/WebhookDriver.js +1 -4
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
- package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/esm/enrichments/parseEnrichmentValue.js +32 -0
- package/esm/enrichments/readEnrichments.d.ts +5 -5
- package/esm/enrichments/readEnrichments.js +17 -7
- package/esm/helpers/collateExamples.js +15 -5
- package/esm/helpers/refFns.d.ts +6 -2
- package/esm/helpers/refFns.js +24 -7
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/oas/array/Array.d.ts +19 -0
- package/esm/oas/array/Array.js +47 -0
- package/esm/oas/boolean/Boolean.d.ts +19 -0
- package/esm/oas/boolean/Boolean.js +51 -8
- package/esm/oas/example/Example.d.ts +4 -0
- package/esm/oas/example/Example.js +8 -0
- package/esm/oas/header/Header.d.ts +4 -0
- package/esm/oas/header/Header.js +8 -0
- package/esm/oas/integer/Integer.d.ts +19 -0
- package/esm/oas/integer/Integer.js +49 -0
- package/esm/oas/link/Link.d.ts +4 -0
- package/esm/oas/link/Link.js +8 -0
- package/esm/oas/number/Number.d.ts +19 -0
- package/esm/oas/number/Number.js +49 -0
- package/esm/oas/object/Object.d.ts +19 -0
- package/esm/oas/object/Object.js +68 -18
- package/esm/oas/operation/Operation.d.ts +8 -1
- package/esm/oas/operation/Operation.js +18 -5
- package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/esm/oas/operation/toEffectiveParameters.js +42 -0
- package/esm/oas/parameter/Parameter.d.ts +4 -0
- package/esm/oas/parameter/Parameter.js +8 -0
- package/esm/oas/ref/DanglingRefError.d.ts +22 -0
- package/esm/oas/ref/DanglingRefError.js +33 -0
- package/esm/oas/ref/Ref.d.ts +152 -25
- package/esm/oas/ref/Ref.js +414 -26
- package/esm/oas/requestBody/RequestBody.d.ts +4 -0
- package/esm/oas/requestBody/RequestBody.js +8 -0
- package/esm/oas/response/Response.d.ts +4 -0
- package/esm/oas/response/Response.js +8 -0
- package/esm/oas/schema/siblings.d.ts +127 -0
- package/esm/oas/schema/siblings.js +250 -0
- package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
- package/esm/oas/string/String.d.ts +19 -0
- package/esm/oas/string/String.js +47 -0
- package/esm/oas/union/Union.d.ts +32 -0
- package/esm/oas/union/Union.js +111 -0
- package/esm/oas/unknown/Unknown.d.ts +18 -0
- package/esm/oas/unknown/Unknown.js +38 -0
- package/esm/oas/void/Void.d.ts +4 -0
- package/esm/oas/void/Void.js +8 -0
- package/esm/oas/webhook/Webhook.d.ts +2 -2
- package/esm/oas/webhook/Webhook.js +4 -5
- package/esm/parse/allOfSystem.d.ts +32 -0
- package/esm/parse/allOfSystem.js +30 -0
- package/esm/parse/anyOfSystem.d.ts +68 -0
- package/esm/parse/anyOfSystem.js +107 -0
- package/esm/parse/securityRequirements.d.ts +6 -0
- package/esm/parse/securityRequirements.js +8 -0
- package/esm/parse/toSiblingKeywords.d.ts +28 -0
- package/esm/parse/toSiblingKeywords.js +109 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
- package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
- package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-0/ref/toRefV31.js +6 -3
- package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-1/ref/toRefV31.js +6 -3
- package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
- package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/esm/parse/v3-2/ref/toRefV31.js +6 -3
- package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/esm/types/OasBase.d.ts +1 -1
- package/esm/types/Settings.d.ts +44 -0
- package/esm/types/Settings.js +9 -0
- package/package.json +5 -1
- package/script/context/CoreContext.js +22 -8
- package/script/context/GenerateContext.d.ts +6 -5
- package/script/context/GenerateContext.js +112 -38
- package/script/context/ParseContext.d.ts +18 -1
- package/script/context/ParseContext.js +102 -3
- package/script/context/generateTypes.d.ts +33 -4
- package/script/context/generateTypes.js +4 -0
- package/script/context/toGenerationFailure.d.ts +21 -0
- package/script/context/toGenerationFailure.js +43 -0
- package/script/context/tryParseAt.d.ts +4 -1
- package/script/context/tryParseAt.js +10 -3
- package/script/dsl/CustomValue.d.ts +4 -0
- package/script/dsl/CustomValue.js +8 -0
- package/script/dsl/Definition.d.ts +10 -0
- package/script/dsl/Definition.js +14 -0
- package/script/dsl/PendingDefinition.d.ts +47 -0
- package/script/dsl/PendingDefinition.js +87 -0
- package/script/dsl/model/ModelDriver.d.ts +55 -1
- package/script/dsl/model/ModelDriver.js +231 -52
- package/script/dsl/model/toModelEntry.d.ts +1 -1
- package/script/dsl/model/toModelEntry.js +1 -1
- package/script/dsl/model/types.d.ts +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
- package/script/dsl/webhook/WebhookDriver.js +1 -4
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
- package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
- package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
- package/script/enrichments/parseEnrichmentValue.js +69 -0
- package/script/enrichments/readEnrichments.d.ts +5 -5
- package/script/enrichments/readEnrichments.js +17 -40
- package/script/helpers/collateExamples.js +15 -5
- package/script/helpers/refFns.d.ts +6 -2
- package/script/helpers/refFns.js +24 -7
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/oas/array/Array.d.ts +19 -0
- package/script/oas/array/Array.js +47 -0
- package/script/oas/boolean/Boolean.d.ts +19 -0
- package/script/oas/boolean/Boolean.js +51 -8
- package/script/oas/example/Example.d.ts +4 -0
- package/script/oas/example/Example.js +8 -0
- package/script/oas/header/Header.d.ts +4 -0
- package/script/oas/header/Header.js +8 -0
- package/script/oas/integer/Integer.d.ts +19 -0
- package/script/oas/integer/Integer.js +49 -0
- package/script/oas/link/Link.d.ts +4 -0
- package/script/oas/link/Link.js +8 -0
- package/script/oas/number/Number.d.ts +19 -0
- package/script/oas/number/Number.js +49 -0
- package/script/oas/object/Object.d.ts +19 -0
- package/script/oas/object/Object.js +68 -18
- package/script/oas/operation/Operation.d.ts +8 -1
- package/script/oas/operation/Operation.js +18 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
- package/script/oas/operation/toEffectiveParameters.js +47 -0
- package/script/oas/parameter/Parameter.d.ts +4 -0
- package/script/oas/parameter/Parameter.js +8 -0
- package/script/oas/ref/DanglingRefError.d.ts +22 -0
- package/script/oas/ref/DanglingRefError.js +37 -0
- package/script/oas/ref/Ref.d.ts +152 -25
- package/script/oas/ref/Ref.js +414 -26
- package/script/oas/requestBody/RequestBody.d.ts +4 -0
- package/script/oas/requestBody/RequestBody.js +8 -0
- package/script/oas/response/Response.d.ts +4 -0
- package/script/oas/response/Response.js +8 -0
- package/script/oas/schema/siblings.d.ts +127 -0
- package/script/oas/schema/siblings.js +305 -0
- package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
- package/script/oas/securitySchemes/SecurityScheme.js +32 -0
- package/script/oas/string/String.d.ts +19 -0
- package/script/oas/string/String.js +47 -0
- package/script/oas/union/Union.d.ts +32 -0
- package/script/oas/union/Union.js +111 -0
- package/script/oas/unknown/Unknown.d.ts +18 -0
- package/script/oas/unknown/Unknown.js +38 -0
- package/script/oas/void/Void.d.ts +4 -0
- package/script/oas/void/Void.js +8 -0
- package/script/oas/webhook/Webhook.d.ts +2 -2
- package/script/oas/webhook/Webhook.js +4 -5
- package/script/parse/allOfSystem.d.ts +32 -0
- package/script/parse/allOfSystem.js +35 -0
- package/script/parse/anyOfSystem.d.ts +68 -0
- package/script/parse/anyOfSystem.js +116 -0
- package/script/parse/securityRequirements.d.ts +6 -0
- package/script/parse/securityRequirements.js +8 -0
- package/script/parse/toSiblingKeywords.d.ts +28 -0
- package/script/parse/toSiblingKeywords.js +146 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
- package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
- package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
- package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
- package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
- package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-0/ref/toRefV31.js +6 -3
- package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
- package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-1/ref/toRefV31.js +6 -3
- package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
- package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
- package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
- package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
- package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
- package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
- package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
- package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
- package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
- package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
- package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
- package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
- package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
- package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
- package/script/parse/v3-2/ref/toRefV31.js +6 -3
- package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
- package/script/types/OasBase.d.ts +1 -1
- package/script/types/Settings.d.ts +44 -0
- package/script/types/Settings.js +10 -1
|
@@ -20,9 +20,10 @@ 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, second, getRef, system }) => {
|
|
24
25
|
if (containsRef(first, second)) {
|
|
25
|
-
return mergeWithRef(first, second, getRef);
|
|
26
|
+
return mergeWithRef({ first, second, getRef, system });
|
|
26
27
|
}
|
|
27
28
|
if ((0, refFns_js_1.isRef)(first)) {
|
|
28
29
|
throw new Error('Ref in first');
|
|
@@ -30,18 +31,30 @@ const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
30
31
|
if ((0, refFns_js_1.isRef)(second)) {
|
|
31
32
|
throw new Error('Ref in second');
|
|
32
33
|
}
|
|
34
|
+
// Under `system.anyOf: unknown` an `anyOf` of two or more members is any
|
|
35
|
+
// value, so it adds nothing to the merge: its members are left out, and the
|
|
36
|
+
// keywords next to it merge as usual.
|
|
37
|
+
const firstKeywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({ schema: first, setting: system.anyOf, getRef });
|
|
38
|
+
const secondKeywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({ schema: second, setting: system.anyOf, getRef });
|
|
39
|
+
if (firstKeywords !== first || secondKeywords !== second) {
|
|
40
|
+
system.unknown?.add('anyOf');
|
|
41
|
+
return (0, exports.mergeSchemasOrRefs)({ first: firstKeywords, second: secondKeywords, getRef, system });
|
|
42
|
+
}
|
|
33
43
|
if (containsAllOf(first) || containsAllOf(second)) {
|
|
34
|
-
|
|
44
|
+
// Each member's own `allOf` merges under the `client.json` setting, also in
|
|
45
|
+
// the strict first pass over a cross product's pairs.
|
|
46
|
+
const ownSystem = (0, merge_union_js_1.toOwnSystem)(system);
|
|
47
|
+
const mergedFirst = containsAllOf(first) ? (0, merge_intersection_js_1.mergeIntersection)({ schema: first, getRef, system: ownSystem }) : first;
|
|
35
48
|
const mergedSecond = containsAllOf(second)
|
|
36
|
-
? (0, merge_intersection_js_1.mergeIntersection)({ schema: second, getRef })
|
|
49
|
+
? (0, merge_intersection_js_1.mergeIntersection)({ schema: second, getRef, system: ownSystem })
|
|
37
50
|
: second;
|
|
38
|
-
return (0, exports.mergeSchemasOrRefs)(mergedFirst, mergedSecond, getRef);
|
|
51
|
+
return (0, exports.mergeSchemasOrRefs)({ first: mergedFirst, second: mergedSecond, getRef, system });
|
|
39
52
|
}
|
|
40
53
|
if (containsOneOf(first, second)) {
|
|
41
|
-
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, groupType: 'oneOf' });
|
|
54
|
+
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, system, groupType: 'oneOf' });
|
|
42
55
|
}
|
|
43
56
|
if (containsAnyOf(first, second)) {
|
|
44
|
-
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, groupType: 'anyOf' });
|
|
57
|
+
return (0, merge_union_js_1.mergeCrossProduct)({ first, second, getRef, system, groupType: 'anyOf' });
|
|
45
58
|
}
|
|
46
59
|
if ((0, nullable_merge_js_1.isNullOnly)(first)) {
|
|
47
60
|
return (0, nullable_merge_js_1.mergeNullOnly)(second);
|
|
@@ -49,7 +62,7 @@ const mergeSchemasOrRefs = (first, second, getRef) => {
|
|
|
49
62
|
if ((0, nullable_merge_js_1.isNullOnly)(second)) {
|
|
50
63
|
return (0, nullable_merge_js_1.mergeNullOnly)(first);
|
|
51
64
|
}
|
|
52
|
-
return mergeSchemas(first, second, getRef);
|
|
65
|
+
return mergeSchemas({ first, second, getRef, system });
|
|
53
66
|
};
|
|
54
67
|
exports.mergeSchemasOrRefs = mergeSchemasOrRefs;
|
|
55
68
|
const containsAllOf = (schema) => {
|
|
@@ -94,48 +107,83 @@ const containsOneOf = (first, second) => {
|
|
|
94
107
|
const containsRef = (first, second) => {
|
|
95
108
|
return (0, refFns_js_1.isRef)(first) || (0, refFns_js_1.isRef)(second);
|
|
96
109
|
};
|
|
97
|
-
|
|
110
|
+
/** Whether one member says `number` and the other `integer`. */
|
|
111
|
+
const isNumberAndInteger = (first, second) => (first.type === 'number' && second.type === 'integer') || (first.type === 'integer' && second.type === 'number');
|
|
112
|
+
const mergeSchemas = ({ first, second, getRef, system }) => {
|
|
113
|
+
// Every integer is a number, so a `number` merged with an `integer` is an
|
|
114
|
+
// `integer` with the constraints of both. Nothing contradicts.
|
|
115
|
+
if (isNumberAndInteger(first, second)) {
|
|
116
|
+
return mergeSchemas({ first: { ...first, type: 'integer' }, second: { ...second, type: 'integer' }, getRef, system });
|
|
117
|
+
}
|
|
118
|
+
if (system.allOf === 'latestWins') {
|
|
119
|
+
// The later member wins a contradiction: a type it disagrees with makes
|
|
120
|
+
// it the whole schema, and any other keyword it disagrees with is left
|
|
121
|
+
// out of the earlier member before they merge.
|
|
122
|
+
if (first.type && second.type && first.type !== second.type) {
|
|
123
|
+
system.replaced.add('type');
|
|
124
|
+
return second;
|
|
125
|
+
}
|
|
126
|
+
const earlier = withoutContradictions({ first, second, replaced: system.replaced });
|
|
127
|
+
return mergeChecked({ first: earlier, second, getRef, system });
|
|
128
|
+
}
|
|
129
|
+
return mergeChecked({ first, second, getRef, system });
|
|
130
|
+
};
|
|
131
|
+
const CONTRADICTIONS = [
|
|
132
|
+
{ check: check_read_only_write_only_conflicts_js_1.checkReadOnlyWriteOnlyConflicts, keywords: ['readOnly', 'writeOnly'] },
|
|
133
|
+
{ check: check_format_conflicts_js_1.checkFormatConflicts, keywords: ['format'] },
|
|
134
|
+
{ check: check_enum_conflicts_js_1.checkEnumConflicts, keywords: ['enum'] },
|
|
135
|
+
{ check: check_number_constraints_conflicts_js_1.checkNumberConstraintsConflicts, keywords: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'] },
|
|
136
|
+
{ check: check_array_item_type_conflicts_js_1.checkArrayItemTypeConflicts, keywords: ['items'] }
|
|
137
|
+
];
|
|
138
|
+
/** `first` without the keywords that contradict `second`, each named in `replaced`. */
|
|
139
|
+
const withoutContradictions = ({ first, second, replaced }) => CONTRADICTIONS.reduce((earlier, { check, keywords }) => {
|
|
98
140
|
try {
|
|
99
|
-
(
|
|
141
|
+
check(earlier, second);
|
|
142
|
+
return earlier;
|
|
100
143
|
}
|
|
101
|
-
catch
|
|
102
|
-
|
|
144
|
+
catch {
|
|
145
|
+
const entries = Object.entries(earlier);
|
|
146
|
+
entries.filter(([key, value]) => keywords.includes(key) && value !== undefined).forEach(([key]) => replaced.add(key));
|
|
147
|
+
return Object.fromEntries(entries.filter(([key]) => !keywords.includes(key)));
|
|
103
148
|
}
|
|
149
|
+
}, first);
|
|
150
|
+
const mergeChecked = ({ first, second, getRef, system }) => {
|
|
151
|
+
(0, check_type_conflicts_js_1.checkTypeConflicts)(first, second);
|
|
104
152
|
(0, check_read_only_write_only_conflicts_js_1.checkReadOnlyWriteOnlyConflicts)(first, second);
|
|
105
153
|
(0, check_format_conflicts_js_1.checkFormatConflicts)(first, second);
|
|
106
154
|
(0, check_enum_conflicts_js_1.checkEnumConflicts)(first, second);
|
|
107
155
|
(0, check_number_constraints_conflicts_js_1.checkNumberConstraintsConflicts)(first, second);
|
|
108
156
|
(0, check_array_item_type_conflicts_js_1.checkArrayItemTypeConflicts)(first, second);
|
|
109
|
-
if (first.not || second.not) {
|
|
157
|
+
if ((first.not || second.not) && system.not !== 'unknown') {
|
|
110
158
|
throw new Error('Merging schemas with "not" keyword is not supported');
|
|
111
159
|
}
|
|
112
|
-
return typedMerge(first, second, getRef);
|
|
160
|
+
return typedMerge({ first, second, getRef, system });
|
|
113
161
|
};
|
|
114
|
-
const typedMerge = (first, second, getRef) => {
|
|
162
|
+
const typedMerge = ({ first, second, getRef, system }) => {
|
|
115
163
|
if (!first.type && !second.type) {
|
|
116
|
-
return (0, generic_merge_js_1.genericMerge)(first, second, getRef);
|
|
164
|
+
return (0, generic_merge_js_1.genericMerge)({ first, second, getRef, system });
|
|
117
165
|
}
|
|
118
166
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'object')) {
|
|
119
|
-
return (0, merge_object_constraints_js_1.mergeObjectConstraints)(first, second, getRef);
|
|
167
|
+
return (0, merge_object_constraints_js_1.mergeObjectConstraints)({ first, second, getRef, system });
|
|
120
168
|
}
|
|
121
169
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'array')) {
|
|
122
|
-
return (0, merge_array_constraints_js_1.mergeArrayConstraints)(first, second, getRef);
|
|
170
|
+
return (0, merge_array_constraints_js_1.mergeArrayConstraints)({ first, second, getRef, system });
|
|
123
171
|
}
|
|
124
172
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'string')) {
|
|
125
|
-
return (0, merge_string_constraints_js_1.mergeStringConstraints)(first, second, getRef);
|
|
173
|
+
return (0, merge_string_constraints_js_1.mergeStringConstraints)({ first, second, getRef, system });
|
|
126
174
|
}
|
|
127
175
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'number')) {
|
|
128
|
-
return (0, merge_number_constraints_js_1.mergeNumberConstraints)(first, second, getRef);
|
|
176
|
+
return (0, merge_number_constraints_js_1.mergeNumberConstraints)({ first, second, getRef, system });
|
|
129
177
|
}
|
|
130
178
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'integer')) {
|
|
131
|
-
return (0, merge_integer_constraints_js_1.mergeIntegerConstraints)(first, second, getRef);
|
|
179
|
+
return (0, merge_integer_constraints_js_1.mergeIntegerConstraints)({ first, second, getRef, system });
|
|
132
180
|
}
|
|
133
181
|
if ((0, check_at_least_one_type_match_js_1.checkAtLeastOneTypeMatch)(first, second, 'boolean')) {
|
|
134
|
-
return (0, merge_boolean_constraints_js_1.mergeBooleanConstraints)(first, second, getRef);
|
|
182
|
+
return (0, merge_boolean_constraints_js_1.mergeBooleanConstraints)({ first, second, getRef, system });
|
|
135
183
|
}
|
|
136
184
|
throw new Error(`Cannot merge schemas with type "${first.type}" with type "${second.type}"`);
|
|
137
185
|
};
|
|
138
|
-
const mergeWithRef = (first, second, getRef) => {
|
|
186
|
+
const mergeWithRef = ({ first, second, getRef, system }) => {
|
|
139
187
|
if ((0, refFns_js_1.isRef)(first) && (0, refFns_js_1.isRef)(second)) {
|
|
140
188
|
if (first.$ref === second.$ref) {
|
|
141
189
|
return {
|
|
@@ -144,15 +192,18 @@ const mergeWithRef = (first, second, getRef) => {
|
|
|
144
192
|
};
|
|
145
193
|
}
|
|
146
194
|
else {
|
|
147
|
-
return
|
|
195
|
+
return (0, exports.mergeSchemasOrRefs)({ first: getRef(first), second: getRef(second), getRef, system });
|
|
148
196
|
}
|
|
149
197
|
}
|
|
198
|
+
// A target followed through its reference merges as any schema does: a
|
|
199
|
+
// `oneOf` or `anyOf` in either one is crossed with the other, not kept
|
|
200
|
+
// beside the merged properties.
|
|
150
201
|
if ((0, refFns_js_1.isRef)(first) && !(0, refFns_js_1.isRef)(second)) {
|
|
151
|
-
const merged = (0, isEmpty_js_1.isEmpty)(second) ? first :
|
|
202
|
+
const merged = (0, isEmpty_js_1.isEmpty)(second) ? first : (0, exports.mergeSchemasOrRefs)({ first: getRef(first), second, getRef, system });
|
|
152
203
|
return merged;
|
|
153
204
|
}
|
|
154
205
|
if (!(0, refFns_js_1.isRef)(first) && (0, refFns_js_1.isRef)(second)) {
|
|
155
|
-
const merged = (0, isEmpty_js_1.isEmpty)(first) ? second :
|
|
206
|
+
const merged = (0, isEmpty_js_1.isEmpty)(first) ? second : (0, exports.mergeSchemasOrRefs)({ first, second: getRef(second), getRef, system });
|
|
156
207
|
return merged;
|
|
157
208
|
}
|
|
158
209
|
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;
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
export type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
|
|
4
|
+
/**
|
|
5
|
+
* The `system` settings as the merge reads them (`client.json#settings.system`),
|
|
6
|
+
* and the keywords a later `allOf` member replaced under `latestWins`, so
|
|
7
|
+
* the parser can name them in one warning for the schema.
|
|
8
|
+
*/
|
|
9
|
+
export type MergeSystem = {
|
|
10
|
+
/** `strict`: a contradiction between members fails the merge. `latestWins`: the later member's keyword wins. */
|
|
11
|
+
allOf: 'strict' | 'latestWins';
|
|
12
|
+
/** `unknown`: a member with `not` merges, its `not` carried as written. Left out: `strict`, which refuses it. */
|
|
13
|
+
not?: 'strict' | 'unknown';
|
|
14
|
+
/**
|
|
15
|
+
* `client.json` `system.allOf`, kept while the first pass over a cross
|
|
16
|
+
* product's pairs sets `allOf` to `strict`. A member's own `allOf` merges
|
|
17
|
+
* under this setting in every pass. Left out: `allOf` is the setting.
|
|
18
|
+
*/
|
|
19
|
+
setting?: 'strict' | 'latestWins';
|
|
20
|
+
replaced: Set<string>;
|
|
21
|
+
/** `unknown`: an `anyOf` of two or more members is any value, so it adds nothing to the merge. Left out: `union`. */
|
|
22
|
+
anyOf?: 'union' | 'unknown';
|
|
23
|
+
/** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
|
|
24
|
+
unknown?: Set<string>;
|
|
25
|
+
};
|
|
4
26
|
export type OneOfObject = {
|
|
5
27
|
oneOf?: (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
|
|
6
28
|
} & OpenAPIV3.SchemaObject;
|
|
@@ -10,5 +32,16 @@ export type AnyOfObject = {
|
|
|
10
32
|
export type SchemaObject = OpenAPIV3.SchemaObject;
|
|
11
33
|
export type ReferenceObject = OpenAPIV3.ReferenceObject;
|
|
12
34
|
export type SchemaOrReference = SchemaObject | ReferenceObject;
|
|
35
|
+
/** Two schemas to merge, how to follow a reference, and the `system` settings: what each merge step takes. */
|
|
36
|
+
export type MergeArgs<Schema = SchemaOrReference> = {
|
|
37
|
+
first: Schema;
|
|
38
|
+
second: Schema;
|
|
39
|
+
getRef: GetRefFn;
|
|
40
|
+
system: MergeSystem;
|
|
41
|
+
};
|
|
42
|
+
/** {@link MergeArgs}, and the valibot schema `default`, `enum` and `example` values must pass. */
|
|
43
|
+
export type GenericMergeArgs<T> = MergeArgs<SchemaObject> & {
|
|
44
|
+
typeCheck?: v.GenericSchema<T>;
|
|
45
|
+
};
|
|
13
46
|
export type ArraySchemaObject = OpenAPIV3.ArraySchemaObject;
|
|
14
47
|
export declare const IntegerSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, "The number must be an integer.">]>;
|
|
@@ -120,13 +120,14 @@ const toMediaTypeItemV3 = ({ mediaTypeItem, mediaType, stackTrail, context }) =>
|
|
|
120
120
|
mediaType,
|
|
121
121
|
encoding,
|
|
122
122
|
schema: stackTrail.trace('schema', st => (0, toSchemasV3_js_1.toOptionalSchemaV3)({ schema, stackTrail: st, context })),
|
|
123
|
-
|
|
123
|
+
// toExamplesV3 traces `examples` (or `example`) itself.
|
|
124
|
+
examples: (0, toExamplesV3_js_1.toExamplesV3)({
|
|
124
125
|
example,
|
|
125
126
|
examples,
|
|
126
127
|
exampleKey: mediaType,
|
|
127
|
-
stackTrail
|
|
128
|
+
stackTrail,
|
|
128
129
|
context
|
|
129
|
-
})
|
|
130
|
+
}),
|
|
130
131
|
extensionFields
|
|
131
132
|
};
|
|
132
133
|
return context.withStackTrail(stackTrail, () => new MediaType_js_1.OasMediaType(fields, context));
|
|
@@ -141,13 +141,14 @@ const toParameterV3 = ({ parameter, stackTrail, context }) => {
|
|
|
141
141
|
allowEmptyValue,
|
|
142
142
|
allowReserved,
|
|
143
143
|
schema: stackTrail.trace('schema', st => (0, toSchemasV3_js_1.toOptionalSchemaV3)({ schema, stackTrail: st, context })),
|
|
144
|
-
|
|
144
|
+
// toExamplesV3 traces `examples` (or `example`) itself.
|
|
145
|
+
examples: (0, toExamplesV3_js_1.toExamplesV3)({
|
|
145
146
|
examples,
|
|
146
147
|
example,
|
|
147
148
|
exampleKey: `${name}-${parsedLocation}`,
|
|
148
|
-
stackTrail
|
|
149
|
+
stackTrail,
|
|
149
150
|
context
|
|
150
|
-
})
|
|
151
|
+
}),
|
|
151
152
|
content: stackTrail.trace('content', st => (0, toMediaTypeItemV3_js_1.toOptionalMediaTypeItemsV3)({ content, stackTrail: st, context })),
|
|
152
153
|
extensionFields
|
|
153
154
|
};
|
|
@@ -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,15 @@ 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
|
-
context.
|
|
12
|
-
|
|
11
|
+
const oasRef = context.withStackTrail(stackTrail, () => new Ref_js_1.OasRef({ ...siblings, refType, $ref, nullable, readOnly, writeOnly }, context));
|
|
12
|
+
// The parse context checks each ref once the document is parsed, and
|
|
13
|
+
// removes what holds a ref that names nothing (`system.danglingRefs`).
|
|
14
|
+
context.registerOasRef(stackTrail.clone(), oasRef);
|
|
15
|
+
return oasRef;
|
|
13
16
|
};
|
|
14
17
|
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,9 +14,28 @@ 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");
|
|
25
|
+
/**
|
|
26
|
+
* `schema` without the members of its `oneOf` or `anyOf` that are 3.0's way to
|
|
27
|
+
* write null (`{ nullable: true, enum: [null] }`, which Cloudflare writes
|
|
28
|
+
* with `type: object` too), and nullable when it had one, as the 3.1 parser
|
|
29
|
+
* folds `{ type: 'null' }` (`partitionNullMember`). A union of null only is
|
|
30
|
+
* left as it is.
|
|
31
|
+
*/
|
|
32
|
+
const withoutNullMembers = (schema, groupType) => {
|
|
33
|
+
const members = schema[groupType] ?? [];
|
|
34
|
+
const nonNull = members.filter(member => (0, refFns_js_1.isRef)(member) || !(0, nullable_merge_js_1.isNullOnly)(member));
|
|
35
|
+
return nonNull.length === 0 || nonNull.length === members.length
|
|
36
|
+
? schema
|
|
37
|
+
: { ...schema, [groupType]: nonNull, nullable: true };
|
|
38
|
+
};
|
|
18
39
|
const toSchemasV3 = ({ schemas, stackTrail, context }) => {
|
|
19
40
|
const output = {};
|
|
20
41
|
const entries = Object.entries(schemas);
|
|
@@ -80,11 +101,28 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
80
101
|
}
|
|
81
102
|
// OpenAPI `not` has no faithful TypeScript representation: a generated type
|
|
82
103
|
// that ignored it would *widen* the contract (accepting shapes the schema
|
|
83
|
-
// forbids).
|
|
84
|
-
// is
|
|
85
|
-
//
|
|
104
|
+
// forbids). Under `client.json` `system.not: strict` (the default) the schema
|
|
105
|
+
// is refused rather than emit a type that lies. The throw is isolated by
|
|
106
|
+
// `tryParseAt` into an `INVALID_SCHEMA` issue, and consumers of this schema
|
|
107
|
+
// are pruned via `removeErroredItems` (INVALID_DEPENDENCY_REF).
|
|
108
|
+
//
|
|
109
|
+
// Under `system.not: unknown` the schema parses with its other keywords, and
|
|
110
|
+
// its `not` is kept as an `OasUnknown` that core does not read: a generator
|
|
111
|
+
// can see that the document says "not something".
|
|
86
112
|
if ('not' in schema) {
|
|
87
|
-
|
|
113
|
+
// A test's mock context may have no `system`.
|
|
114
|
+
if (context.system?.not !== 'unknown') {
|
|
115
|
+
throw new Error('Schema uses unsupported "not" keyword');
|
|
116
|
+
}
|
|
117
|
+
const { not: _not, ...keywords } = schema;
|
|
118
|
+
const parsed = (0, exports.toSchemaV3)({ schema: keywords, stackTrail, context });
|
|
119
|
+
// Only a one-member `allOf` of a `$ref` parses to a reference, and a
|
|
120
|
+
// reference has no field for a `not`. Fail rather than lose it.
|
|
121
|
+
if (parsed.isRef()) {
|
|
122
|
+
throw new Error('Schema uses "not" next to a one-member allOf reference, which cannot keep it');
|
|
123
|
+
}
|
|
124
|
+
parsed.not = stackTrail.trace('not', notTrail => context.withStackTrail(notTrail, () => new Unknown_js_1.OasUnknown({}, context)));
|
|
125
|
+
return parsed;
|
|
88
126
|
}
|
|
89
127
|
if ('allOf' in schema && Array.isArray(schema.allOf)) {
|
|
90
128
|
return stackTrail.trace('allOf', st => {
|
|
@@ -100,14 +138,40 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
100
138
|
const members = allOf ?? [];
|
|
101
139
|
if (members.length === 1) {
|
|
102
140
|
const [member] = members;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
141
|
+
// Keywords next to the one member say how this site uses the
|
|
142
|
+
// reference, which stays lazy, so a self-reference still ends:
|
|
143
|
+
// `nullable`, `readOnly` and `writeOnly` ride it as use-site flags,
|
|
144
|
+
// and the others are read without the target's type (`siblings`).
|
|
145
|
+
// `resolve()` applies them to a copy of the target at generate time;
|
|
146
|
+
// the ones its type cannot take are left out there. The shared model
|
|
147
|
+
// never changes.
|
|
148
|
+
if ((0, refFns_js_1.isRef)(member)) {
|
|
149
|
+
const { nullable, readOnly, writeOnly, ...keywords } = value;
|
|
150
|
+
const siblings = (0, isEmpty_js_1.isEmpty)(keywords)
|
|
151
|
+
? undefined
|
|
152
|
+
: (0, toSiblingKeywords_js_1.toSiblingKeywords)({
|
|
153
|
+
keywords,
|
|
154
|
+
properties: stackTrail.trace('properties', propertiesTrail => (0, exports.toOptionalSchemasV3)({ schemas: keywords.properties, stackTrail: propertiesTrail, context })),
|
|
155
|
+
additionalProperties: stackTrail.trace('additionalProperties', additionalTrail => (0, toAdditionalPropertiesV3_js_1.toAdditionalPropertiesV3)({
|
|
156
|
+
additionalProperties: keywords.additionalProperties,
|
|
157
|
+
stackTrail: additionalTrail,
|
|
158
|
+
context
|
|
159
|
+
})),
|
|
160
|
+
stackTrail,
|
|
161
|
+
context
|
|
162
|
+
});
|
|
163
|
+
if (nullable || readOnly || writeOnly || siblings) {
|
|
164
|
+
return (0, toRefV31_js_1.toRefV31)({
|
|
165
|
+
ref: member,
|
|
166
|
+
refType: 'schema',
|
|
167
|
+
nullable: nullable || undefined,
|
|
168
|
+
readOnly: readOnly || undefined,
|
|
169
|
+
writeOnly: writeOnly || undefined,
|
|
170
|
+
siblings,
|
|
171
|
+
stackTrail: st,
|
|
172
|
+
context
|
|
173
|
+
});
|
|
174
|
+
}
|
|
111
175
|
}
|
|
112
176
|
return (0, exports.toSchemaV3)({
|
|
113
177
|
schema: collapseSingleMember(value, member),
|
|
@@ -115,20 +179,29 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
115
179
|
context
|
|
116
180
|
});
|
|
117
181
|
}
|
|
182
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
118
183
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
119
184
|
schema,
|
|
120
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject)
|
|
185
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
186
|
+
system
|
|
121
187
|
});
|
|
188
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
189
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
122
190
|
return (0, exports.toSchemaV3)({ schema: merged, stackTrail: st, context });
|
|
123
191
|
});
|
|
124
192
|
}
|
|
125
193
|
if ('oneOf' in schema && Array.isArray(schema.oneOf)) {
|
|
126
194
|
return stackTrail.trace('oneOf', st => {
|
|
195
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
127
196
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
128
|
-
|
|
197
|
+
// A null member makes the union nullable: `oneOf: [$ref, null]` is a nullable reference.
|
|
198
|
+
schema: withoutNullMembers(schema, 'oneOf'),
|
|
129
199
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
200
|
+
system,
|
|
130
201
|
groupType: 'oneOf'
|
|
131
202
|
});
|
|
203
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
204
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
132
205
|
if (!('oneOf' in merged) || !Array.isArray(merged.oneOf)) {
|
|
133
206
|
throw new Error('Missing "oneOf" array');
|
|
134
207
|
}
|
|
@@ -166,6 +239,21 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
166
239
|
});
|
|
167
240
|
}
|
|
168
241
|
if ('anyOf' in schema && Array.isArray(schema.anyOf)) {
|
|
242
|
+
// Under `system.anyOf: unknown`, as Cloudflare's `cf` reads it, an `anyOf`
|
|
243
|
+
// of two or more members is any value: the schema parses with its other
|
|
244
|
+
// keywords, so the properties next to it stay, without the members.
|
|
245
|
+
if ((0, anyOfSystem_js_1.isUnknownAnyOf)({ members: schema.anyOf, setting: context.system?.anyOf, getRef: (0, refFns_js_2.toGetRef)(context.documentObject) })) {
|
|
246
|
+
(0, anyOfSystem_js_1.logUnknownAnyOf)({ stackTrail, parent: schema, context });
|
|
247
|
+
const keywords = (0, anyOfSystem_js_1.withoutUnknownAnyOf)({
|
|
248
|
+
schema,
|
|
249
|
+
setting: context.system?.anyOf,
|
|
250
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject)
|
|
251
|
+
});
|
|
252
|
+
// A `default` alone is no type: the parser would guess one from it.
|
|
253
|
+
return (0, anyOfSystem_js_1.hasShapeKeyword)(keywords)
|
|
254
|
+
? (0, exports.toSchemaV3)({ schema: keywords, stackTrail, context })
|
|
255
|
+
: (0, toUnknown_js_1.toUnknown)({ value: keywords, stackTrail, context });
|
|
256
|
+
}
|
|
169
257
|
return stackTrail.trace('anyOf', st => {
|
|
170
258
|
// deno-lint-ignore ban-ts-comment
|
|
171
259
|
// @ts-expect-error
|
|
@@ -173,11 +261,15 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
173
261
|
const { anyOf, ...value } = schema;
|
|
174
262
|
return (0, toUnion_js_1.toUnion)({ value, members: anyOf, parentType: 'anyOf', stackTrail: st, context });
|
|
175
263
|
}
|
|
264
|
+
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
176
265
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
177
|
-
schema,
|
|
266
|
+
schema: withoutNullMembers(schema, 'anyOf'),
|
|
178
267
|
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
268
|
+
system,
|
|
179
269
|
groupType: 'anyOf'
|
|
180
270
|
});
|
|
271
|
+
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
272
|
+
(0, anyOfSystem_js_1.logMergedUnknownAnyOf)({ system, stackTrail, parent: schema, context });
|
|
181
273
|
if (!('anyOf' in merged) || !Array.isArray(merged.anyOf)) {
|
|
182
274
|
throw new Error('Missing "anyOf" array');
|
|
183
275
|
}
|
|
@@ -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;
|