@typia/utils 13.0.0-dev.20260427-3 → 13.0.0-dev.20260501
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/lib/converters/LlmSchemaConverter.js +6 -6
- package/lib/converters/LlmSchemaConverter.js.map +1 -1
- package/lib/converters/LlmSchemaConverter.mjs +2 -7
- package/lib/converters/LlmSchemaConverter.mjs.map +1 -1
- package/lib/converters/LlmSchemaConverter2.mjs +449 -451
- package/lib/converters/LlmSchemaConverter2.mjs.map +1 -1
- package/lib/converters/OpenApiConverter.mjs +2 -7
- package/lib/converters/OpenApiConverter.mjs.map +1 -1
- package/lib/converters/OpenApiConverter2.mjs +163 -164
- package/lib/converters/OpenApiConverter2.mjs.map +1 -1
- package/lib/converters/index.mjs +1 -7
- package/lib/converters/index.mjs.map +1 -1
- package/lib/converters/index2.mjs +31 -32
- package/lib/converters/index2.mjs.map +1 -1
- package/lib/converters/internal/LlmDescriptionInverter.mjs +2 -7
- package/lib/converters/internal/LlmDescriptionInverter.mjs.map +1 -1
- package/lib/converters/internal/LlmDescriptionInverter2.mjs +143 -150
- package/lib/converters/internal/LlmDescriptionInverter2.mjs.map +1 -1
- package/lib/converters/internal/LlmParametersComposer.mjs +2 -7
- package/lib/converters/internal/LlmParametersComposer.mjs.map +1 -1
- package/lib/converters/internal/LlmParametersComposer2.mjs +37 -44
- package/lib/converters/internal/LlmParametersComposer2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiConstraintShifter.mjs +2 -7
- package/lib/converters/internal/OpenApiConstraintShifter.mjs.map +1 -1
- package/lib/converters/internal/OpenApiConstraintShifter2.mjs +105 -112
- package/lib/converters/internal/OpenApiConstraintShifter2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs +2 -7
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs.map +1 -1
- package/lib/converters/internal/OpenApiExclusiveEmender2.mjs +32 -40
- package/lib/converters/internal/OpenApiExclusiveEmender2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3Downgrader.mjs +2 -7
- package/lib/converters/internal/OpenApiV3Downgrader.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3Downgrader2.mjs +237 -244
- package/lib/converters/internal/OpenApiV3Downgrader2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3Upgrader.mjs +2 -7
- package/lib/converters/internal/OpenApiV3Upgrader.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3Upgrader2.mjs +300 -305
- package/lib/converters/internal/OpenApiV3Upgrader2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_1Downgrader.mjs +2 -7
- package/lib/converters/internal/OpenApiV3_1Downgrader.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_1Downgrader2.mjs +193 -200
- package/lib/converters/internal/OpenApiV3_1Downgrader2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs +2 -7
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_1Upgrader2.mjs +424 -429
- package/lib/converters/internal/OpenApiV3_1Upgrader2.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_2Upgrader.mjs +2 -7
- package/lib/converters/internal/OpenApiV3_2Upgrader.mjs.map +1 -1
- package/lib/converters/internal/OpenApiV3_2Upgrader2.mjs +202 -208
- package/lib/converters/internal/OpenApiV3_2Upgrader2.mjs.map +1 -1
- package/lib/converters/internal/SwaggerV2Downgrader.mjs +2 -7
- package/lib/converters/internal/SwaggerV2Downgrader.mjs.map +1 -1
- package/lib/converters/internal/SwaggerV2Downgrader2.mjs +287 -294
- package/lib/converters/internal/SwaggerV2Downgrader2.mjs.map +1 -1
- package/lib/converters/internal/SwaggerV2Upgrader.mjs +2 -7
- package/lib/converters/internal/SwaggerV2Upgrader.mjs.map +1 -1
- package/lib/converters/internal/SwaggerV2Upgrader2.mjs +370 -375
- package/lib/converters/internal/SwaggerV2Upgrader2.mjs.map +1 -1
- package/lib/http/HttpError.mjs +2 -7
- package/lib/http/HttpError.mjs.map +1 -1
- package/lib/http/HttpError2.mjs +69 -77
- package/lib/http/HttpError2.mjs.map +1 -1
- package/lib/http/HttpLlm.mjs +2 -7
- package/lib/http/HttpLlm.mjs.map +1 -1
- package/lib/http/HttpLlm2.mjs +107 -112
- package/lib/http/HttpLlm2.mjs.map +1 -1
- package/lib/http/HttpMigration.mjs +2 -7
- package/lib/http/HttpMigration.mjs.map +1 -1
- package/lib/http/HttpMigration2.mjs +58 -63
- package/lib/http/HttpMigration2.mjs.map +1 -1
- package/lib/http/index.mjs +1 -7
- package/lib/http/index.mjs.map +1 -1
- package/lib/http/index2.mjs +30 -31
- package/lib/http/index2.mjs.map +1 -1
- package/lib/http/internal/HttpLlmApplicationComposer.mjs +2 -7
- package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
- package/lib/http/internal/HttpLlmApplicationComposer2.mjs +301 -306
- package/lib/http/internal/HttpLlmApplicationComposer2.mjs.map +1 -1
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs +2 -7
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs.map +1 -1
- package/lib/http/internal/HttpLlmFunctionFetcher2.mjs +26 -33
- package/lib/http/internal/HttpLlmFunctionFetcher2.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs +2 -7
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateApplicationComposer2.mjs +51 -56
- package/lib/http/internal/HttpMigrateApplicationComposer2.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs +2 -7
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteAccessor2.mjs +113 -118
- package/lib/http/internal/HttpMigrateRouteAccessor2.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteComposer.mjs +2 -7
- package/lib/http/internal/HttpMigrateRouteComposer.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteComposer2.mjs +376 -381
- package/lib/http/internal/HttpMigrateRouteComposer2.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs +2 -7
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs.map +1 -1
- package/lib/http/internal/HttpMigrateRouteFetcher2.mjs +182 -189
- package/lib/http/internal/HttpMigrateRouteFetcher2.mjs.map +1 -1
- package/lib/index.mjs +1 -7
- package/lib/index.mjs.map +1 -1
- package/lib/index2.mjs +33 -33
- package/lib/index2.mjs.map +1 -1
- package/lib/utils/ArrayUtil.mjs +2 -7
- package/lib/utils/ArrayUtil.mjs.map +1 -1
- package/lib/utils/ArrayUtil2.mjs +29 -37
- package/lib/utils/ArrayUtil2.mjs.map +1 -1
- package/lib/utils/LlmJson.mjs +2 -7
- package/lib/utils/LlmJson.mjs.map +1 -1
- package/lib/utils/LlmJson2.mjs +166 -169
- package/lib/utils/LlmJson2.mjs.map +1 -1
- package/lib/utils/MapUtil.mjs +2 -7
- package/lib/utils/MapUtil.mjs.map +1 -1
- package/lib/utils/MapUtil2.mjs +16 -24
- package/lib/utils/MapUtil2.mjs.map +1 -1
- package/lib/utils/NamingConvention.mjs +2 -7
- package/lib/utils/NamingConvention.mjs.map +1 -1
- package/lib/utils/NamingConvention2.mjs +199 -207
- package/lib/utils/NamingConvention2.mjs.map +1 -1
- package/lib/utils/Singleton.d.ts +1 -6
- package/lib/utils/Singleton.js +1 -0
- package/lib/utils/Singleton.js.map +1 -1
- package/lib/utils/Singleton.mjs +2 -7
- package/lib/utils/Singleton.mjs.map +1 -1
- package/lib/utils/Singleton2.mjs +17 -24
- package/lib/utils/Singleton2.mjs.map +1 -1
- package/lib/utils/StringUtil.mjs +2 -7
- package/lib/utils/StringUtil.mjs.map +1 -1
- package/lib/utils/StringUtil2.mjs +14 -22
- package/lib/utils/StringUtil2.mjs.map +1 -1
- package/lib/utils/dedent.mjs +2 -7
- package/lib/utils/dedent.mjs.map +1 -1
- package/lib/utils/dedent2.mjs +50 -58
- package/lib/utils/dedent2.mjs.map +1 -1
- package/lib/utils/index.mjs +1 -7
- package/lib/utils/index.mjs.map +1 -1
- package/lib/utils/index2.mjs +42 -39
- package/lib/utils/index2.mjs.map +1 -1
- package/lib/utils/internal/EndpointUtil.mjs +2 -7
- package/lib/utils/internal/EndpointUtil.mjs.map +1 -1
- package/lib/utils/internal/EndpointUtil2.mjs +39 -46
- package/lib/utils/internal/EndpointUtil2.mjs.map +1 -1
- package/lib/utils/internal/JsonDescriptor.mjs +2 -7
- package/lib/utils/internal/JsonDescriptor.mjs.map +1 -1
- package/lib/utils/internal/JsonDescriptor2.mjs +55 -61
- package/lib/utils/internal/JsonDescriptor2.mjs.map +1 -1
- package/lib/utils/internal/OpenApiTypeCheckerBase.js +23 -14
- package/lib/utils/internal/OpenApiTypeCheckerBase.js.map +1 -1
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs +2 -7
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs.map +1 -1
- package/lib/utils/internal/OpenApiTypeCheckerBase2.mjs +539 -536
- package/lib/utils/internal/OpenApiTypeCheckerBase2.mjs.map +1 -1
- package/lib/utils/internal/coerceLlmArguments.js +27 -1
- package/lib/utils/internal/coerceLlmArguments.js.map +1 -1
- package/lib/utils/internal/coerceLlmArguments.mjs +2 -7
- package/lib/utils/internal/coerceLlmArguments.mjs.map +1 -1
- package/lib/utils/internal/coerceLlmArguments2.mjs +278 -258
- package/lib/utils/internal/coerceLlmArguments2.mjs.map +1 -1
- package/lib/utils/internal/parseLenientJson.mjs +2 -7
- package/lib/utils/internal/parseLenientJson.mjs.map +1 -1
- package/lib/utils/internal/parseLenientJson2.mjs +803 -811
- package/lib/utils/internal/parseLenientJson2.mjs.map +1 -1
- package/lib/utils/internal/stringifyValidationFailure.mjs +2 -7
- package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
- package/lib/utils/internal/stringifyValidationFailure2.mjs +310 -316
- package/lib/utils/internal/stringifyValidationFailure2.mjs.map +1 -1
- package/lib/validators/LlmTypeChecker.mjs +2 -7
- package/lib/validators/LlmTypeChecker.mjs.map +1 -1
- package/lib/validators/LlmTypeChecker2.mjs +314 -320
- package/lib/validators/LlmTypeChecker2.mjs.map +1 -1
- package/lib/validators/OpenApiTypeChecker.mjs +2 -7
- package/lib/validators/OpenApiTypeChecker.mjs.map +1 -1
- package/lib/validators/OpenApiTypeChecker2.mjs +209 -216
- package/lib/validators/OpenApiTypeChecker2.mjs.map +1 -1
- package/lib/validators/OpenApiV3TypeChecker.mjs +2 -7
- package/lib/validators/OpenApiV3TypeChecker.mjs.map +1 -1
- package/lib/validators/OpenApiV3TypeChecker2.mjs +30 -38
- package/lib/validators/OpenApiV3TypeChecker2.mjs.map +1 -1
- package/lib/validators/OpenApiV3_1TypeChecker.mjs +2 -7
- package/lib/validators/OpenApiV3_1TypeChecker.mjs.map +1 -1
- package/lib/validators/OpenApiV3_1TypeChecker2.mjs +34 -42
- package/lib/validators/OpenApiV3_1TypeChecker2.mjs.map +1 -1
- package/lib/validators/OpenApiValidator.mjs +2 -7
- package/lib/validators/OpenApiValidator.mjs.map +1 -1
- package/lib/validators/OpenApiValidator2.mjs +73 -80
- package/lib/validators/OpenApiValidator2.mjs.map +1 -1
- package/lib/validators/SwaggerV2TypeChecker.mjs +2 -7
- package/lib/validators/SwaggerV2TypeChecker.mjs.map +1 -1
- package/lib/validators/SwaggerV2TypeChecker2.mjs +31 -39
- package/lib/validators/SwaggerV2TypeChecker2.mjs.map +1 -1
- package/lib/validators/functional/_isBigintString.mjs +2 -7
- package/lib/validators/functional/_isBigintString.mjs.map +1 -1
- package/lib/validators/functional/_isBigintString2.mjs +14 -22
- package/lib/validators/functional/_isBigintString2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatByte.mjs +2 -7
- package/lib/validators/functional/_isFormatByte.mjs.map +1 -1
- package/lib/validators/functional/_isFormatByte2.mjs +10 -18
- package/lib/validators/functional/_isFormatByte2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDate.mjs +2 -7
- package/lib/validators/functional/_isFormatDate.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDate2.mjs +7 -15
- package/lib/validators/functional/_isFormatDate2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDateTime.mjs +2 -7
- package/lib/validators/functional/_isFormatDateTime.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDateTime2.mjs +7 -15
- package/lib/validators/functional/_isFormatDateTime2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDuration.mjs +2 -7
- package/lib/validators/functional/_isFormatDuration.mjs.map +1 -1
- package/lib/validators/functional/_isFormatDuration2.mjs +7 -15
- package/lib/validators/functional/_isFormatDuration2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatEmail.mjs +2 -7
- package/lib/validators/functional/_isFormatEmail.mjs.map +1 -1
- package/lib/validators/functional/_isFormatEmail2.mjs +7 -15
- package/lib/validators/functional/_isFormatEmail2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatHostname.mjs +2 -7
- package/lib/validators/functional/_isFormatHostname.mjs.map +1 -1
- package/lib/validators/functional/_isFormatHostname2.mjs +7 -15
- package/lib/validators/functional/_isFormatHostname2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIdnEmail.mjs +2 -7
- package/lib/validators/functional/_isFormatIdnEmail.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIdnEmail2.mjs +7 -15
- package/lib/validators/functional/_isFormatIdnEmail2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIdnHostname.mjs +2 -7
- package/lib/validators/functional/_isFormatIdnHostname.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIdnHostname2.mjs +7 -15
- package/lib/validators/functional/_isFormatIdnHostname2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIpv4.mjs +2 -7
- package/lib/validators/functional/_isFormatIpv4.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIpv42.mjs +7 -15
- package/lib/validators/functional/_isFormatIpv42.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIpv6.mjs +2 -7
- package/lib/validators/functional/_isFormatIpv6.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIpv62.mjs +7 -15
- package/lib/validators/functional/_isFormatIpv62.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIri.mjs +2 -7
- package/lib/validators/functional/_isFormatIri.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIri2.mjs +7 -15
- package/lib/validators/functional/_isFormatIri2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIriReference.mjs +2 -7
- package/lib/validators/functional/_isFormatIriReference.mjs.map +1 -1
- package/lib/validators/functional/_isFormatIriReference2.mjs +7 -15
- package/lib/validators/functional/_isFormatIriReference2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatJsonPointer.mjs +2 -7
- package/lib/validators/functional/_isFormatJsonPointer.mjs.map +1 -1
- package/lib/validators/functional/_isFormatJsonPointer2.mjs +7 -15
- package/lib/validators/functional/_isFormatJsonPointer2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatPassword.mjs +2 -7
- package/lib/validators/functional/_isFormatPassword.mjs.map +1 -1
- package/lib/validators/functional/_isFormatPassword2.mjs +6 -14
- package/lib/validators/functional/_isFormatPassword2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatRegex.mjs +2 -7
- package/lib/validators/functional/_isFormatRegex.mjs.map +1 -1
- package/lib/validators/functional/_isFormatRegex2.mjs +14 -22
- package/lib/validators/functional/_isFormatRegex2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs +2 -7
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/validators/functional/_isFormatRelativeJsonPointer2.mjs +7 -15
- package/lib/validators/functional/_isFormatRelativeJsonPointer2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatTime.mjs +2 -7
- package/lib/validators/functional/_isFormatTime.mjs.map +1 -1
- package/lib/validators/functional/_isFormatTime2.mjs +7 -15
- package/lib/validators/functional/_isFormatTime2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUri.mjs +2 -7
- package/lib/validators/functional/_isFormatUri.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUri2.mjs +8 -16
- package/lib/validators/functional/_isFormatUri2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUriReference.mjs +2 -7
- package/lib/validators/functional/_isFormatUriReference.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUriReference2.mjs +7 -15
- package/lib/validators/functional/_isFormatUriReference2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUriTemplate.mjs +2 -7
- package/lib/validators/functional/_isFormatUriTemplate.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUriTemplate2.mjs +7 -15
- package/lib/validators/functional/_isFormatUriTemplate2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUrl.mjs +2 -7
- package/lib/validators/functional/_isFormatUrl.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUrl2.mjs +7 -15
- package/lib/validators/functional/_isFormatUrl2.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUuid.mjs +2 -7
- package/lib/validators/functional/_isFormatUuid.mjs.map +1 -1
- package/lib/validators/functional/_isFormatUuid2.mjs +7 -15
- package/lib/validators/functional/_isFormatUuid2.mjs.map +1 -1
- package/lib/validators/functional/_isUniqueItems.mjs +2 -7
- package/lib/validators/functional/_isUniqueItems.mjs.map +1 -1
- package/lib/validators/functional/_isUniqueItems2.mjs +140 -148
- package/lib/validators/functional/_isUniqueItems2.mjs.map +1 -1
- package/lib/validators/index.mjs +1 -7
- package/lib/validators/index.mjs.map +1 -1
- package/lib/validators/index2.mjs +42 -40
- package/lib/validators/index2.mjs.map +1 -1
- package/lib/validators/internal/IOpenApiValidatorContext.mjs +2 -7
- package/lib/validators/internal/IOpenApiValidatorContext.mjs.map +1 -1
- package/lib/validators/internal/IOpenApiValidatorContext2.mjs +2 -10
- package/lib/validators/internal/IOpenApiValidatorContext2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiArrayValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiArrayValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiArrayValidator2.mjs +36 -42
- package/lib/validators/internal/OpenApiArrayValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiBooleanValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiBooleanValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiBooleanValidator2.mjs +10 -18
- package/lib/validators/internal/OpenApiBooleanValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiConstantValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiConstantValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiConstantValidator2.mjs +10 -18
- package/lib/validators/internal/OpenApiConstantValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiIntegerValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiIntegerValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiIntegerValidator2.mjs +33 -41
- package/lib/validators/internal/OpenApiIntegerValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiNumberValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiNumberValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiNumberValidator2.mjs +33 -41
- package/lib/validators/internal/OpenApiNumberValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiObjectValidator.js +2 -3
- package/lib/validators/internal/OpenApiObjectValidator.js.map +1 -1
- package/lib/validators/internal/OpenApiObjectValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiObjectValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiObjectValidator2.mjs +55 -62
- package/lib/validators/internal/OpenApiObjectValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiOneOfValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiOneOfValidator2.mjs +188 -193
- package/lib/validators/internal/OpenApiOneOfValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs +2 -7
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs.map +1 -1
- package/lib/validators/internal/OpenApiSchemaNamingRule2.mjs +124 -131
- package/lib/validators/internal/OpenApiSchemaNamingRule2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiStationValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiStationValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiStationValidator2.mjs +86 -83
- package/lib/validators/internal/OpenApiStationValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiStringValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiStringValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiStringValidator2.mjs +115 -102
- package/lib/validators/internal/OpenApiStringValidator2.mjs.map +1 -1
- package/lib/validators/internal/OpenApiTupleValidator.mjs +2 -7
- package/lib/validators/internal/OpenApiTupleValidator.mjs.map +1 -1
- package/lib/validators/internal/OpenApiTupleValidator2.mjs +33 -40
- package/lib/validators/internal/OpenApiTupleValidator2.mjs.map +1 -1
- package/package.json +4 -4
- package/src/converters/LlmSchemaConverter.ts +1 -1
- package/src/utils/Singleton.ts +1 -0
- package/src/utils/internal/OpenApiTypeCheckerBase.ts +12 -3
- package/src/utils/internal/coerceLlmArguments.ts +27 -1
- package/src/validators/internal/OpenApiObjectValidator.ts +1 -2
|
@@ -1,297 +1,290 @@
|
|
|
1
|
-
import { __exports as SwaggerV2Downgrader } from '../../_virtual/SwaggerV2Downgrader.mjs';
|
|
2
|
-
import
|
|
1
|
+
import { __exports as SwaggerV2Downgrader$1 } from '../../_virtual/SwaggerV2Downgrader.mjs';
|
|
2
|
+
import '../../validators/OpenApiTypeChecker2.mjs';
|
|
3
|
+
import { __exports as OpenApiTypeChecker } from '../../_virtual/OpenApiTypeChecker.mjs';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
Object.defineProperty(SwaggerV2Downgrader$1, "__esModule", { value: true });
|
|
6
|
+
var SwaggerV2Downgrader_2 = SwaggerV2Downgrader$1.SwaggerV2Downgrader = void 0;
|
|
7
|
+
const OpenApiTypeChecker_1 = OpenApiTypeChecker;
|
|
8
|
+
var SwaggerV2Downgrader;
|
|
9
|
+
(function (SwaggerV2Downgrader) {
|
|
10
|
+
SwaggerV2Downgrader.downgrade = (input) => {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const collection = SwaggerV2Downgrader.downgradeComponents(input.components);
|
|
13
|
+
return {
|
|
14
|
+
swagger: "2.0",
|
|
15
|
+
info: input.info,
|
|
16
|
+
host: ((_b = (_a = input.servers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.url)
|
|
17
|
+
? input.servers[0].url.split("://").pop()
|
|
18
|
+
: "",
|
|
19
|
+
definitions: collection.downgraded,
|
|
20
|
+
securityDefinitions: ((_c = input.components) === null || _c === void 0 ? void 0 : _c.securitySchemes)
|
|
21
|
+
? Object.fromEntries(Object.entries(input.components.securitySchemes)
|
|
22
|
+
.filter(([_, v]) => v !== undefined)
|
|
23
|
+
.map(([key, value]) => downgradeSecurityScheme(value).map((v) => [key, v]))
|
|
24
|
+
.flat())
|
|
25
|
+
: undefined,
|
|
26
|
+
paths: input.paths
|
|
27
|
+
? Object.fromEntries(Object.entries(input.paths)
|
|
28
|
+
.filter(([_, v]) => v !== undefined)
|
|
29
|
+
.map(([key, value]) => [key, downgradePathItem(collection)(value)]))
|
|
30
|
+
: undefined,
|
|
31
|
+
security: input.security,
|
|
32
|
+
tags: input.tags,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/* -----------------------------------------------------------
|
|
36
|
+
OPERATORS
|
|
37
|
+
----------------------------------------------------------- */
|
|
38
|
+
const downgradePathItem = (collection) => (pathItem) => {
|
|
39
|
+
// Collect non-standard operations for x-additionalOperations
|
|
40
|
+
const xAdditionalOperations = {};
|
|
41
|
+
// query method goes to x-additionalOperations
|
|
42
|
+
if (pathItem.query) {
|
|
43
|
+
xAdditionalOperations["query"] = downgradeOperation(collection)(pathItem.query);
|
|
44
|
+
}
|
|
45
|
+
// additionalOperations also go to x-additionalOperations
|
|
46
|
+
if (pathItem.additionalOperations) {
|
|
47
|
+
for (const [key, value] of Object.entries(pathItem.additionalOperations)) {
|
|
48
|
+
if (value !== undefined) {
|
|
49
|
+
xAdditionalOperations[key] = downgradeOperation(collection)(value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, pathItem), (pathItem.get
|
|
54
|
+
? { get: downgradeOperation(collection)(pathItem.get) }
|
|
55
|
+
: undefined)), (pathItem.put
|
|
56
|
+
? { put: downgradeOperation(collection)(pathItem.put) }
|
|
57
|
+
: undefined)), (pathItem.post
|
|
58
|
+
? { post: downgradeOperation(collection)(pathItem.post) }
|
|
59
|
+
: undefined)), (pathItem.delete
|
|
60
|
+
? { delete: downgradeOperation(collection)(pathItem.delete) }
|
|
61
|
+
: undefined)), (pathItem.options
|
|
62
|
+
? { options: downgradeOperation(collection)(pathItem.options) }
|
|
63
|
+
: undefined)), (pathItem.head
|
|
64
|
+
? { head: downgradeOperation(collection)(pathItem.head) }
|
|
65
|
+
: undefined)), (pathItem.patch
|
|
66
|
+
? { patch: downgradeOperation(collection)(pathItem.patch) }
|
|
67
|
+
: undefined)), (pathItem.trace
|
|
68
|
+
? { trace: downgradeOperation(collection)(pathItem.trace) }
|
|
69
|
+
: undefined)), (Object.keys(xAdditionalOperations).length > 0
|
|
70
|
+
? { "x-additionalOperations": xAdditionalOperations }
|
|
71
|
+
: undefined)), {
|
|
72
|
+
// Remove v3.2-only properties from spread
|
|
73
|
+
query: undefined, additionalOperations: undefined });
|
|
74
|
+
};
|
|
75
|
+
const downgradeOperation = (collection) => (input) => { var _a; return (Object.assign(Object.assign(Object.assign({}, input), { parameters: input.parameters !== undefined || input.requestBody !== undefined
|
|
76
|
+
? [
|
|
77
|
+
...((_a = input.parameters) !== null && _a !== void 0 ? _a : []).map(downgradeParameter(collection)),
|
|
78
|
+
...(input.requestBody
|
|
79
|
+
? [downgradeRequestBody(collection)(input.requestBody)]
|
|
80
|
+
: []),
|
|
81
|
+
]
|
|
82
|
+
: undefined, responses: input.responses
|
|
83
|
+
? Object.fromEntries(Object.entries(input.responses)
|
|
84
|
+
.filter(([_, v]) => v !== undefined)
|
|
85
|
+
.map(([key, value]) => [
|
|
86
|
+
key,
|
|
87
|
+
downgradeResponse(collection)(value),
|
|
88
|
+
]))
|
|
89
|
+
: undefined }), {
|
|
90
|
+
requestBody: undefined,
|
|
91
|
+
servers: undefined,
|
|
92
|
+
})); };
|
|
93
|
+
const downgradeParameter = (collection) => (input, i) => { var _a; var _b; return (Object.assign(Object.assign(Object.assign(Object.assign({}, SwaggerV2Downgrader.downgradeSchema(collection)(input.schema)), input), { in: input.in === "querystring" ? "query" : input.in, required: (_a = input.schema) === null || _a === void 0 ? void 0 : _a.required, schema: undefined, name: (_b = input.name) !== null && _b !== void 0 ? _b : `p${i}` }), {
|
|
94
|
+
example: undefined,
|
|
95
|
+
examples: undefined,
|
|
96
|
+
})); };
|
|
97
|
+
const downgradeRequestBody = (collection) => (input) => { var _a; var _b, _c; return ({
|
|
98
|
+
name: "body",
|
|
99
|
+
in: "body",
|
|
100
|
+
description: input.description,
|
|
101
|
+
required: input.required,
|
|
102
|
+
schema: SwaggerV2Downgrader.downgradeSchema(collection)((_c = (_a = Object.values((_b = input.content) !== null && _b !== void 0 ? _b : {})[0]) === null || _a === void 0 ? void 0 : _a.schema) !== null && _c !== void 0 ? _c : {}),
|
|
103
|
+
}); };
|
|
104
|
+
const downgradeResponse = (collection) => (input) => { var _a; var _b, _c; return ({
|
|
105
|
+
description: input.description,
|
|
106
|
+
schema: SwaggerV2Downgrader.downgradeSchema(collection)((_c = (_a = Object.values((_b = input.content) !== null && _b !== void 0 ? _b : {})[0]) === null || _a === void 0 ? void 0 : _a.schema) !== null && _c !== void 0 ? _c : {}),
|
|
107
|
+
headers: input.headers
|
|
108
|
+
? Object.fromEntries(Object.entries(input.headers)
|
|
109
|
+
.filter(([_, v]) => v !== undefined)
|
|
110
|
+
.map(([key, value]) => [
|
|
111
|
+
key,
|
|
112
|
+
Object.assign(Object.assign(Object.assign({}, value), { schema: SwaggerV2Downgrader.downgradeSchema(collection)(value.schema) }), {
|
|
113
|
+
example: undefined,
|
|
114
|
+
examples: undefined,
|
|
115
|
+
}),
|
|
116
|
+
]))
|
|
117
|
+
: undefined,
|
|
118
|
+
}); };
|
|
119
|
+
/* -----------------------------------------------------------
|
|
120
|
+
DEFINITIONS
|
|
121
|
+
----------------------------------------------------------- */
|
|
122
|
+
SwaggerV2Downgrader.downgradeComponents = (input) => {
|
|
123
|
+
const collection = {
|
|
124
|
+
original: input,
|
|
125
|
+
downgraded: {},
|
|
126
|
+
};
|
|
127
|
+
if (input.schemas) {
|
|
128
|
+
collection.downgraded.schemas = {};
|
|
129
|
+
for (const [key, value] of Object.entries(input.schemas))
|
|
130
|
+
if (value !== undefined)
|
|
131
|
+
collection.downgraded[key.split("/").pop()] =
|
|
132
|
+
SwaggerV2Downgrader.downgradeSchema(collection)(value);
|
|
133
|
+
}
|
|
134
|
+
return collection;
|
|
135
|
+
};
|
|
136
|
+
SwaggerV2Downgrader.downgradeSchema = (collection) => (input) => {
|
|
137
|
+
const nullable = isNullable(new Set())(collection.original)(input);
|
|
138
|
+
const union = [];
|
|
139
|
+
const attribute = Object.assign({ title: input.title, description: input.description, deprecated: input.deprecated, readOnly: input.readOnly, example: input.example, examples: input.examples ? Object.values(input.examples) : undefined }, Object.fromEntries(Object.entries(input).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
|
|
140
|
+
const visit = (schema) => {
|
|
141
|
+
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema))
|
|
142
|
+
union.push({ type: "boolean" });
|
|
143
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema) ||
|
|
144
|
+
OpenApiTypeChecker_1.OpenApiTypeChecker.isInteger(schema) ||
|
|
145
|
+
OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(schema) ||
|
|
146
|
+
OpenApiTypeChecker_1.OpenApiTypeChecker.isString(schema))
|
|
147
|
+
union.push(Object.assign(Object.assign({}, schema), { examples: schema.examples
|
|
148
|
+
? Object.values(schema.examples)
|
|
149
|
+
: undefined }));
|
|
150
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema))
|
|
151
|
+
union.push({ $ref: `#/definitions/${schema.$ref.split("/").pop()}` });
|
|
152
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(schema))
|
|
153
|
+
union.push(Object.assign(Object.assign({}, schema), { items: SwaggerV2Downgrader.downgradeSchema(collection)(schema.items), examples: schema.examples
|
|
154
|
+
? Object.values(schema.examples)
|
|
155
|
+
: undefined }));
|
|
156
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(schema))
|
|
157
|
+
union.push(Object.assign(Object.assign(Object.assign(Object.assign({}, schema), { items: (() => {
|
|
158
|
+
if (schema.additionalItems === true)
|
|
159
|
+
return {};
|
|
160
|
+
const elements = [
|
|
161
|
+
...schema.prefixItems,
|
|
162
|
+
...(typeof schema.additionalItems === "object"
|
|
163
|
+
? [SwaggerV2Downgrader.downgradeSchema(collection)(schema.additionalItems)]
|
|
164
|
+
: []),
|
|
165
|
+
];
|
|
166
|
+
if (elements.length === 0)
|
|
167
|
+
return {};
|
|
168
|
+
return {
|
|
169
|
+
"x-oneOf": elements.map(SwaggerV2Downgrader.downgradeSchema(collection)),
|
|
170
|
+
};
|
|
171
|
+
})(), minItems: schema.prefixItems.length, maxItems: !!schema.additionalItems === true
|
|
172
|
+
? undefined
|
|
173
|
+
: schema.prefixItems.length }), {
|
|
174
|
+
prefixItems: undefined,
|
|
175
|
+
additionalItems: undefined,
|
|
176
|
+
}), { examples: schema.examples
|
|
177
|
+
? Object.values(schema.examples)
|
|
178
|
+
: undefined }));
|
|
179
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(schema))
|
|
180
|
+
union.push(Object.assign(Object.assign({}, schema), { properties: schema.properties
|
|
181
|
+
? Object.fromEntries(Object.entries(schema.properties)
|
|
182
|
+
.filter(([_, v]) => v !== undefined)
|
|
183
|
+
.map(([key, value]) => [
|
|
184
|
+
key,
|
|
185
|
+
SwaggerV2Downgrader.downgradeSchema(collection)(value),
|
|
186
|
+
]))
|
|
187
|
+
: undefined, additionalProperties: typeof schema.additionalProperties === "object"
|
|
188
|
+
? SwaggerV2Downgrader.downgradeSchema(collection)(schema.additionalProperties)
|
|
189
|
+
: schema.additionalProperties, required: schema.required, examples: schema.examples
|
|
190
|
+
? Object.values(schema.examples)
|
|
191
|
+
: undefined }));
|
|
192
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema))
|
|
193
|
+
schema.oneOf.forEach(visit);
|
|
194
|
+
};
|
|
195
|
+
visit(input);
|
|
196
|
+
if (nullable) {
|
|
197
|
+
for (const u of union)
|
|
198
|
+
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(u))
|
|
199
|
+
downgradeNullableReference(new Set())(collection)(u);
|
|
200
|
+
else
|
|
201
|
+
u["x-nullable"] = true;
|
|
202
|
+
}
|
|
203
|
+
if (nullable === true && union.length === 0)
|
|
204
|
+
return Object.assign({ type: "null" }, attribute);
|
|
205
|
+
return Object.assign(Object.assign(Object.assign({}, (union.length === 0
|
|
206
|
+
? { type: undefined }
|
|
207
|
+
: union.length === 1
|
|
208
|
+
? Object.assign({}, union[0]) : { "x-oneOf": union })), attribute), (union.length > 1 ? { discriminator: undefined } : {}));
|
|
209
|
+
};
|
|
210
|
+
const downgradeNullableReference = (visited) => (collection) => (schema) => {
|
|
211
|
+
var _a;
|
|
212
|
+
const key = schema.$ref.split("/").pop();
|
|
213
|
+
if (key.endsWith(".Nullable"))
|
|
214
|
+
return;
|
|
215
|
+
const found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key];
|
|
216
|
+
if (found === undefined)
|
|
217
|
+
return;
|
|
218
|
+
else if (isNullable(visited)(collection.original)(found) === true)
|
|
219
|
+
return;
|
|
220
|
+
else if (collection.downgraded[`${key}.Nullable`] === undefined) {
|
|
221
|
+
collection.downgraded[`${key}.Nullable`] = {};
|
|
222
|
+
collection.downgraded[`${key}.Nullable`] = SwaggerV2Downgrader.downgradeSchema(collection)(OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(found)
|
|
223
|
+
? Object.assign(Object.assign({}, found), { oneOf: [...found.oneOf, { type: "null" }] }) : Object.assign(Object.assign({ title: found.title, description: found.description, example: found.example, examples: found.examples
|
|
224
|
+
? Object.values(found.examples)
|
|
225
|
+
: undefined }, Object.fromEntries(Object.entries(found).filter(([key, value]) => key.startsWith("x-") && value !== undefined))), { oneOf: [found, { type: "null" }] }));
|
|
226
|
+
}
|
|
227
|
+
schema.$ref += ".Nullable";
|
|
228
|
+
};
|
|
229
|
+
const downgradeSecurityScheme = (input) => {
|
|
230
|
+
if (input.type === "apiKey")
|
|
231
|
+
return [input];
|
|
232
|
+
else if (input.type === "http")
|
|
233
|
+
if (input.scheme === "basic")
|
|
234
|
+
return [{ type: "basic", description: input.description }];
|
|
235
|
+
else
|
|
236
|
+
return [];
|
|
237
|
+
else if (input.type === "oauth2") {
|
|
238
|
+
const output = [];
|
|
239
|
+
if (input.flows.implicit)
|
|
240
|
+
output.push({
|
|
241
|
+
type: "oauth2",
|
|
242
|
+
flow: "implicit",
|
|
243
|
+
authorizationUrl: input.flows.implicit.authorizationUrl,
|
|
244
|
+
scopes: input.flows.implicit.scopes,
|
|
245
|
+
});
|
|
246
|
+
if (input.flows.password)
|
|
247
|
+
output.push({
|
|
248
|
+
type: "oauth2",
|
|
249
|
+
flow: "password",
|
|
250
|
+
tokenUrl: input.flows.password.tokenUrl,
|
|
251
|
+
scopes: input.flows.password.scopes,
|
|
252
|
+
});
|
|
253
|
+
if (input.flows.clientCredentials)
|
|
254
|
+
output.push({
|
|
255
|
+
type: "oauth2",
|
|
256
|
+
flow: "application",
|
|
257
|
+
tokenUrl: input.flows.clientCredentials.tokenUrl,
|
|
258
|
+
scopes: input.flows.clientCredentials.scopes,
|
|
259
|
+
});
|
|
260
|
+
if (input.flows.authorizationCode)
|
|
261
|
+
output.push({
|
|
262
|
+
type: "oauth2",
|
|
263
|
+
flow: "accessCode",
|
|
264
|
+
authorizationUrl: input.flows.authorizationCode.authorizationUrl,
|
|
265
|
+
tokenUrl: input.flows.authorizationCode.tokenUrl,
|
|
266
|
+
scopes: input.flows.authorizationCode.scopes,
|
|
267
|
+
});
|
|
268
|
+
return output;
|
|
269
|
+
}
|
|
270
|
+
return [];
|
|
271
|
+
};
|
|
272
|
+
const isNullable = (visited) => (components) => (schema) => {
|
|
273
|
+
var _a;
|
|
274
|
+
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(schema))
|
|
275
|
+
return true;
|
|
276
|
+
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema)) {
|
|
277
|
+
if (visited.has(schema.$ref))
|
|
278
|
+
return false;
|
|
279
|
+
visited.add(schema.$ref);
|
|
280
|
+
const key = schema.$ref.split("/").pop();
|
|
281
|
+
const next = (_a = components.schemas) === null || _a === void 0 ? void 0 : _a[key];
|
|
282
|
+
return next ? isNullable(visited)(components)(next) : false;
|
|
283
|
+
}
|
|
284
|
+
return (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema) &&
|
|
285
|
+
schema.oneOf.some(isNullable(visited)(components)));
|
|
286
|
+
};
|
|
287
|
+
})(SwaggerV2Downgrader || (SwaggerV2Downgrader_2 = SwaggerV2Downgrader$1.SwaggerV2Downgrader = SwaggerV2Downgrader = {}));
|
|
5
288
|
|
|
6
|
-
|
|
7
|
-
if (hasRequiredSwaggerV2Downgrader) return SwaggerV2Downgrader;
|
|
8
|
-
hasRequiredSwaggerV2Downgrader = 1;
|
|
9
|
-
Object.defineProperty(SwaggerV2Downgrader, "__esModule", { value: true });
|
|
10
|
-
SwaggerV2Downgrader.SwaggerV2Downgrader = void 0;
|
|
11
|
-
const OpenApiTypeChecker_1 = requireOpenApiTypeChecker();
|
|
12
|
-
var SwaggerV2Downgrader$1;
|
|
13
|
-
(function (SwaggerV2Downgrader) {
|
|
14
|
-
SwaggerV2Downgrader.downgrade = (input) => {
|
|
15
|
-
var _a, _b, _c;
|
|
16
|
-
const collection = SwaggerV2Downgrader.downgradeComponents(input.components);
|
|
17
|
-
return {
|
|
18
|
-
swagger: "2.0",
|
|
19
|
-
info: input.info,
|
|
20
|
-
host: ((_b = (_a = input.servers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.url)
|
|
21
|
-
? input.servers[0].url.split("://").pop()
|
|
22
|
-
: "",
|
|
23
|
-
definitions: collection.downgraded,
|
|
24
|
-
securityDefinitions: ((_c = input.components) === null || _c === void 0 ? void 0 : _c.securitySchemes)
|
|
25
|
-
? Object.fromEntries(Object.entries(input.components.securitySchemes)
|
|
26
|
-
.filter(([_, v]) => v !== undefined)
|
|
27
|
-
.map(([key, value]) => downgradeSecurityScheme(value).map((v) => [key, v]))
|
|
28
|
-
.flat())
|
|
29
|
-
: undefined,
|
|
30
|
-
paths: input.paths
|
|
31
|
-
? Object.fromEntries(Object.entries(input.paths)
|
|
32
|
-
.filter(([_, v]) => v !== undefined)
|
|
33
|
-
.map(([key, value]) => [key, downgradePathItem(collection)(value)]))
|
|
34
|
-
: undefined,
|
|
35
|
-
security: input.security,
|
|
36
|
-
tags: input.tags,
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
/* -----------------------------------------------------------
|
|
40
|
-
OPERATORS
|
|
41
|
-
----------------------------------------------------------- */
|
|
42
|
-
const downgradePathItem = (collection) => (pathItem) => {
|
|
43
|
-
// Collect non-standard operations for x-additionalOperations
|
|
44
|
-
const xAdditionalOperations = {};
|
|
45
|
-
// query method goes to x-additionalOperations
|
|
46
|
-
if (pathItem.query) {
|
|
47
|
-
xAdditionalOperations["query"] = downgradeOperation(collection)(pathItem.query);
|
|
48
|
-
}
|
|
49
|
-
// additionalOperations also go to x-additionalOperations
|
|
50
|
-
if (pathItem.additionalOperations) {
|
|
51
|
-
for (const [key, value] of Object.entries(pathItem.additionalOperations)) {
|
|
52
|
-
if (value !== undefined) {
|
|
53
|
-
xAdditionalOperations[key] = downgradeOperation(collection)(value);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, pathItem), (pathItem.get
|
|
58
|
-
? { get: downgradeOperation(collection)(pathItem.get) }
|
|
59
|
-
: undefined)), (pathItem.put
|
|
60
|
-
? { put: downgradeOperation(collection)(pathItem.put) }
|
|
61
|
-
: undefined)), (pathItem.post
|
|
62
|
-
? { post: downgradeOperation(collection)(pathItem.post) }
|
|
63
|
-
: undefined)), (pathItem.delete
|
|
64
|
-
? { delete: downgradeOperation(collection)(pathItem.delete) }
|
|
65
|
-
: undefined)), (pathItem.options
|
|
66
|
-
? { options: downgradeOperation(collection)(pathItem.options) }
|
|
67
|
-
: undefined)), (pathItem.head
|
|
68
|
-
? { head: downgradeOperation(collection)(pathItem.head) }
|
|
69
|
-
: undefined)), (pathItem.patch
|
|
70
|
-
? { patch: downgradeOperation(collection)(pathItem.patch) }
|
|
71
|
-
: undefined)), (pathItem.trace
|
|
72
|
-
? { trace: downgradeOperation(collection)(pathItem.trace) }
|
|
73
|
-
: undefined)), (Object.keys(xAdditionalOperations).length > 0
|
|
74
|
-
? { "x-additionalOperations": xAdditionalOperations }
|
|
75
|
-
: undefined)), {
|
|
76
|
-
// Remove v3.2-only properties from spread
|
|
77
|
-
query: undefined, additionalOperations: undefined });
|
|
78
|
-
};
|
|
79
|
-
const downgradeOperation = (collection) => (input) => { var _a; return (Object.assign(Object.assign(Object.assign({}, input), { parameters: input.parameters !== undefined || input.requestBody !== undefined
|
|
80
|
-
? [
|
|
81
|
-
...((_a = input.parameters) !== null && _a !== void 0 ? _a : []).map(downgradeParameter(collection)),
|
|
82
|
-
...(input.requestBody
|
|
83
|
-
? [downgradeRequestBody(collection)(input.requestBody)]
|
|
84
|
-
: []),
|
|
85
|
-
]
|
|
86
|
-
: undefined, responses: input.responses
|
|
87
|
-
? Object.fromEntries(Object.entries(input.responses)
|
|
88
|
-
.filter(([_, v]) => v !== undefined)
|
|
89
|
-
.map(([key, value]) => [
|
|
90
|
-
key,
|
|
91
|
-
downgradeResponse(collection)(value),
|
|
92
|
-
]))
|
|
93
|
-
: undefined }), {
|
|
94
|
-
requestBody: undefined,
|
|
95
|
-
servers: undefined,
|
|
96
|
-
})); };
|
|
97
|
-
const downgradeParameter = (collection) => (input, i) => { var _a; var _b; return (Object.assign(Object.assign(Object.assign(Object.assign({}, SwaggerV2Downgrader.downgradeSchema(collection)(input.schema)), input), { in: input.in === "querystring" ? "query" : input.in, required: (_a = input.schema) === null || _a === void 0 ? void 0 : _a.required, schema: undefined, name: (_b = input.name) !== null && _b !== void 0 ? _b : `p${i}` }), {
|
|
98
|
-
example: undefined,
|
|
99
|
-
examples: undefined,
|
|
100
|
-
})); };
|
|
101
|
-
const downgradeRequestBody = (collection) => (input) => { var _a; var _b, _c; return ({
|
|
102
|
-
name: "body",
|
|
103
|
-
in: "body",
|
|
104
|
-
description: input.description,
|
|
105
|
-
required: input.required,
|
|
106
|
-
schema: SwaggerV2Downgrader.downgradeSchema(collection)((_c = (_a = Object.values((_b = input.content) !== null && _b !== void 0 ? _b : {})[0]) === null || _a === void 0 ? void 0 : _a.schema) !== null && _c !== void 0 ? _c : {}),
|
|
107
|
-
}); };
|
|
108
|
-
const downgradeResponse = (collection) => (input) => { var _a; var _b, _c; return ({
|
|
109
|
-
description: input.description,
|
|
110
|
-
schema: SwaggerV2Downgrader.downgradeSchema(collection)((_c = (_a = Object.values((_b = input.content) !== null && _b !== void 0 ? _b : {})[0]) === null || _a === void 0 ? void 0 : _a.schema) !== null && _c !== void 0 ? _c : {}),
|
|
111
|
-
headers: input.headers
|
|
112
|
-
? Object.fromEntries(Object.entries(input.headers)
|
|
113
|
-
.filter(([_, v]) => v !== undefined)
|
|
114
|
-
.map(([key, value]) => [
|
|
115
|
-
key,
|
|
116
|
-
Object.assign(Object.assign(Object.assign({}, value), { schema: SwaggerV2Downgrader.downgradeSchema(collection)(value.schema) }), {
|
|
117
|
-
example: undefined,
|
|
118
|
-
examples: undefined,
|
|
119
|
-
}),
|
|
120
|
-
]))
|
|
121
|
-
: undefined,
|
|
122
|
-
}); };
|
|
123
|
-
/* -----------------------------------------------------------
|
|
124
|
-
DEFINITIONS
|
|
125
|
-
----------------------------------------------------------- */
|
|
126
|
-
SwaggerV2Downgrader.downgradeComponents = (input) => {
|
|
127
|
-
const collection = {
|
|
128
|
-
original: input,
|
|
129
|
-
downgraded: {},
|
|
130
|
-
};
|
|
131
|
-
if (input.schemas) {
|
|
132
|
-
collection.downgraded.schemas = {};
|
|
133
|
-
for (const [key, value] of Object.entries(input.schemas))
|
|
134
|
-
if (value !== undefined)
|
|
135
|
-
collection.downgraded[key.split("/").pop()] =
|
|
136
|
-
SwaggerV2Downgrader.downgradeSchema(collection)(value);
|
|
137
|
-
}
|
|
138
|
-
return collection;
|
|
139
|
-
};
|
|
140
|
-
SwaggerV2Downgrader.downgradeSchema = (collection) => (input) => {
|
|
141
|
-
const nullable = isNullable(new Set())(collection.original)(input);
|
|
142
|
-
const union = [];
|
|
143
|
-
const attribute = Object.assign({ title: input.title, description: input.description, deprecated: input.deprecated, readOnly: input.readOnly, example: input.example, examples: input.examples ? Object.values(input.examples) : undefined }, Object.fromEntries(Object.entries(input).filter(([key, value]) => key.startsWith("x-") && value !== undefined)));
|
|
144
|
-
const visit = (schema) => {
|
|
145
|
-
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema))
|
|
146
|
-
union.push({ type: "boolean" });
|
|
147
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isBoolean(schema) ||
|
|
148
|
-
OpenApiTypeChecker_1.OpenApiTypeChecker.isInteger(schema) ||
|
|
149
|
-
OpenApiTypeChecker_1.OpenApiTypeChecker.isNumber(schema) ||
|
|
150
|
-
OpenApiTypeChecker_1.OpenApiTypeChecker.isString(schema))
|
|
151
|
-
union.push(Object.assign(Object.assign({}, schema), { examples: schema.examples
|
|
152
|
-
? Object.values(schema.examples)
|
|
153
|
-
: undefined }));
|
|
154
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema))
|
|
155
|
-
union.push({ $ref: `#/definitions/${schema.$ref.split("/").pop()}` });
|
|
156
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(schema))
|
|
157
|
-
union.push(Object.assign(Object.assign({}, schema), { items: SwaggerV2Downgrader.downgradeSchema(collection)(schema.items), examples: schema.examples
|
|
158
|
-
? Object.values(schema.examples)
|
|
159
|
-
: undefined }));
|
|
160
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isTuple(schema))
|
|
161
|
-
union.push(Object.assign(Object.assign(Object.assign(Object.assign({}, schema), { items: (() => {
|
|
162
|
-
if (schema.additionalItems === true)
|
|
163
|
-
return {};
|
|
164
|
-
const elements = [
|
|
165
|
-
...schema.prefixItems,
|
|
166
|
-
...(typeof schema.additionalItems === "object"
|
|
167
|
-
? [SwaggerV2Downgrader.downgradeSchema(collection)(schema.additionalItems)]
|
|
168
|
-
: []),
|
|
169
|
-
];
|
|
170
|
-
if (elements.length === 0)
|
|
171
|
-
return {};
|
|
172
|
-
return {
|
|
173
|
-
"x-oneOf": elements.map(SwaggerV2Downgrader.downgradeSchema(collection)),
|
|
174
|
-
};
|
|
175
|
-
})(), minItems: schema.prefixItems.length, maxItems: !!schema.additionalItems === true
|
|
176
|
-
? undefined
|
|
177
|
-
: schema.prefixItems.length }), {
|
|
178
|
-
prefixItems: undefined,
|
|
179
|
-
additionalItems: undefined,
|
|
180
|
-
}), { examples: schema.examples
|
|
181
|
-
? Object.values(schema.examples)
|
|
182
|
-
: undefined }));
|
|
183
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isObject(schema))
|
|
184
|
-
union.push(Object.assign(Object.assign({}, schema), { properties: schema.properties
|
|
185
|
-
? Object.fromEntries(Object.entries(schema.properties)
|
|
186
|
-
.filter(([_, v]) => v !== undefined)
|
|
187
|
-
.map(([key, value]) => [
|
|
188
|
-
key,
|
|
189
|
-
SwaggerV2Downgrader.downgradeSchema(collection)(value),
|
|
190
|
-
]))
|
|
191
|
-
: undefined, additionalProperties: typeof schema.additionalProperties === "object"
|
|
192
|
-
? SwaggerV2Downgrader.downgradeSchema(collection)(schema.additionalProperties)
|
|
193
|
-
: schema.additionalProperties, required: schema.required, examples: schema.examples
|
|
194
|
-
? Object.values(schema.examples)
|
|
195
|
-
: undefined }));
|
|
196
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema))
|
|
197
|
-
schema.oneOf.forEach(visit);
|
|
198
|
-
};
|
|
199
|
-
visit(input);
|
|
200
|
-
if (nullable) {
|
|
201
|
-
for (const u of union)
|
|
202
|
-
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(u))
|
|
203
|
-
downgradeNullableReference(new Set())(collection)(u);
|
|
204
|
-
else
|
|
205
|
-
u["x-nullable"] = true;
|
|
206
|
-
}
|
|
207
|
-
if (nullable === true && union.length === 0)
|
|
208
|
-
return Object.assign({ type: "null" }, attribute);
|
|
209
|
-
return Object.assign(Object.assign(Object.assign({}, (union.length === 0
|
|
210
|
-
? { type: undefined }
|
|
211
|
-
: union.length === 1
|
|
212
|
-
? Object.assign({}, union[0]) : { "x-oneOf": union })), attribute), (union.length > 1 ? { discriminator: undefined } : {}));
|
|
213
|
-
};
|
|
214
|
-
const downgradeNullableReference = (visited) => (collection) => (schema) => {
|
|
215
|
-
var _a;
|
|
216
|
-
const key = schema.$ref.split("/").pop();
|
|
217
|
-
if (key.endsWith(".Nullable"))
|
|
218
|
-
return;
|
|
219
|
-
const found = (_a = collection.original.schemas) === null || _a === void 0 ? void 0 : _a[key];
|
|
220
|
-
if (found === undefined)
|
|
221
|
-
return;
|
|
222
|
-
else if (isNullable(visited)(collection.original)(found) === true)
|
|
223
|
-
return;
|
|
224
|
-
else if (collection.downgraded[`${key}.Nullable`] === undefined) {
|
|
225
|
-
collection.downgraded[`${key}.Nullable`] = {};
|
|
226
|
-
collection.downgraded[`${key}.Nullable`] = SwaggerV2Downgrader.downgradeSchema(collection)(OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(found)
|
|
227
|
-
? Object.assign(Object.assign({}, found), { oneOf: [...found.oneOf, { type: "null" }] }) : Object.assign(Object.assign({ title: found.title, description: found.description, example: found.example, examples: found.examples
|
|
228
|
-
? Object.values(found.examples)
|
|
229
|
-
: undefined }, Object.fromEntries(Object.entries(found).filter(([key, value]) => key.startsWith("x-") && value !== undefined))), { oneOf: [found, { type: "null" }] }));
|
|
230
|
-
}
|
|
231
|
-
schema.$ref += ".Nullable";
|
|
232
|
-
};
|
|
233
|
-
const downgradeSecurityScheme = (input) => {
|
|
234
|
-
if (input.type === "apiKey")
|
|
235
|
-
return [input];
|
|
236
|
-
else if (input.type === "http")
|
|
237
|
-
if (input.scheme === "basic")
|
|
238
|
-
return [{ type: "basic", description: input.description }];
|
|
239
|
-
else
|
|
240
|
-
return [];
|
|
241
|
-
else if (input.type === "oauth2") {
|
|
242
|
-
const output = [];
|
|
243
|
-
if (input.flows.implicit)
|
|
244
|
-
output.push({
|
|
245
|
-
type: "oauth2",
|
|
246
|
-
flow: "implicit",
|
|
247
|
-
authorizationUrl: input.flows.implicit.authorizationUrl,
|
|
248
|
-
scopes: input.flows.implicit.scopes,
|
|
249
|
-
});
|
|
250
|
-
if (input.flows.password)
|
|
251
|
-
output.push({
|
|
252
|
-
type: "oauth2",
|
|
253
|
-
flow: "password",
|
|
254
|
-
tokenUrl: input.flows.password.tokenUrl,
|
|
255
|
-
scopes: input.flows.password.scopes,
|
|
256
|
-
});
|
|
257
|
-
if (input.flows.clientCredentials)
|
|
258
|
-
output.push({
|
|
259
|
-
type: "oauth2",
|
|
260
|
-
flow: "application",
|
|
261
|
-
tokenUrl: input.flows.clientCredentials.tokenUrl,
|
|
262
|
-
scopes: input.flows.clientCredentials.scopes,
|
|
263
|
-
});
|
|
264
|
-
if (input.flows.authorizationCode)
|
|
265
|
-
output.push({
|
|
266
|
-
type: "oauth2",
|
|
267
|
-
flow: "accessCode",
|
|
268
|
-
authorizationUrl: input.flows.authorizationCode.authorizationUrl,
|
|
269
|
-
tokenUrl: input.flows.authorizationCode.tokenUrl,
|
|
270
|
-
scopes: input.flows.authorizationCode.scopes,
|
|
271
|
-
});
|
|
272
|
-
return output;
|
|
273
|
-
}
|
|
274
|
-
return [];
|
|
275
|
-
};
|
|
276
|
-
const isNullable = (visited) => (components) => (schema) => {
|
|
277
|
-
var _a;
|
|
278
|
-
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isNull(schema))
|
|
279
|
-
return true;
|
|
280
|
-
else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(schema)) {
|
|
281
|
-
if (visited.has(schema.$ref))
|
|
282
|
-
return false;
|
|
283
|
-
visited.add(schema.$ref);
|
|
284
|
-
const key = schema.$ref.split("/").pop();
|
|
285
|
-
const next = (_a = components.schemas) === null || _a === void 0 ? void 0 : _a[key];
|
|
286
|
-
return next ? isNullable(visited)(components)(next) : false;
|
|
287
|
-
}
|
|
288
|
-
return (OpenApiTypeChecker_1.OpenApiTypeChecker.isOneOf(schema) &&
|
|
289
|
-
schema.oneOf.some(isNullable(visited)(components)));
|
|
290
|
-
};
|
|
291
|
-
})(SwaggerV2Downgrader$1 || (SwaggerV2Downgrader.SwaggerV2Downgrader = SwaggerV2Downgrader$1 = {}));
|
|
292
|
-
|
|
293
|
-
return SwaggerV2Downgrader;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export { requireSwaggerV2Downgrader as __require };
|
|
289
|
+
export { SwaggerV2Downgrader_2 as SwaggerV2Downgrader, SwaggerV2Downgrader$1 as default };
|
|
297
290
|
//# sourceMappingURL=SwaggerV2Downgrader2.mjs.map
|