@typia/utils 12.0.0-dev.20260225
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/LICENSE +21 -0
- package/README.md +79 -0
- package/lib/converters/LlmSchemaConverter.d.ts +102 -0
- package/lib/converters/LlmSchemaConverter.js +652 -0
- package/lib/converters/LlmSchemaConverter.js.map +1 -0
- package/lib/converters/LlmSchemaConverter.mjs +771 -0
- package/lib/converters/LlmSchemaConverter.mjs.map +1 -0
- package/lib/converters/OpenApiConverter.d.ts +135 -0
- package/lib/converters/OpenApiConverter.js +130 -0
- package/lib/converters/OpenApiConverter.js.map +1 -0
- package/lib/converters/OpenApiConverter.mjs +128 -0
- package/lib/converters/OpenApiConverter.mjs.map +1 -0
- package/lib/converters/index.d.ts +2 -0
- package/lib/converters/index.js +21 -0
- package/lib/converters/index.js.map +1 -0
- package/lib/converters/index.mjs +4 -0
- package/lib/converters/index.mjs.map +1 -0
- package/lib/converters/internal/LlmDescriptionInverter.d.ts +6 -0
- package/lib/converters/internal/LlmDescriptionInverter.js +141 -0
- package/lib/converters/internal/LlmDescriptionInverter.js.map +1 -0
- package/lib/converters/internal/LlmDescriptionInverter.mjs +141 -0
- package/lib/converters/internal/LlmDescriptionInverter.mjs.map +1 -0
- package/lib/converters/internal/LlmParametersComposer.d.ts +1 -0
- package/lib/converters/internal/LlmParametersComposer.js +39 -0
- package/lib/converters/internal/LlmParametersComposer.js.map +1 -0
- package/lib/converters/internal/LlmParametersComposer.mjs +42 -0
- package/lib/converters/internal/LlmParametersComposer.mjs.map +1 -0
- package/lib/converters/internal/OpenApiConstraintShifter.d.ts +6 -0
- package/lib/converters/internal/OpenApiConstraintShifter.js +103 -0
- package/lib/converters/internal/OpenApiConstraintShifter.js.map +1 -0
- package/lib/converters/internal/OpenApiConstraintShifter.mjs +102 -0
- package/lib/converters/internal/OpenApiConstraintShifter.mjs.map +1 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.d.ts +4 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.js +32 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.js.map +1 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs +35 -0
- package/lib/converters/internal/OpenApiExclusiveEmender.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3Downgrader.d.ts +10 -0
- package/lib/converters/internal/OpenApiV3Downgrader.js +214 -0
- package/lib/converters/internal/OpenApiV3Downgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3Downgrader.mjs +279 -0
- package/lib/converters/internal/OpenApiV3Downgrader.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3Upgrader.d.ts +6 -0
- package/lib/converters/internal/OpenApiV3Upgrader.js +285 -0
- package/lib/converters/internal/OpenApiV3Upgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3Upgrader.mjs +349 -0
- package/lib/converters/internal/OpenApiV3Upgrader.mjs.map +1 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.d.ts +6 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.js +405 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.js.map +1 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs +545 -0
- package/lib/converters/internal/OpenApiV3_1Upgrader.mjs.map +1 -0
- package/lib/converters/internal/SwaggerV2Downgrader.d.ts +10 -0
- package/lib/converters/internal/SwaggerV2Downgrader.js +294 -0
- package/lib/converters/internal/SwaggerV2Downgrader.js.map +1 -0
- package/lib/converters/internal/SwaggerV2Downgrader.mjs +332 -0
- package/lib/converters/internal/SwaggerV2Downgrader.mjs.map +1 -0
- package/lib/converters/internal/SwaggerV2Upgrader.d.ts +6 -0
- package/lib/converters/internal/SwaggerV2Upgrader.js +357 -0
- package/lib/converters/internal/SwaggerV2Upgrader.js.map +1 -0
- package/lib/converters/internal/SwaggerV2Upgrader.mjs +403 -0
- package/lib/converters/internal/SwaggerV2Upgrader.mjs.map +1 -0
- package/lib/http/HttpError.d.ts +61 -0
- package/lib/http/HttpError.js +70 -0
- package/lib/http/HttpError.js.map +1 -0
- package/lib/http/HttpError.mjs +76 -0
- package/lib/http/HttpError.mjs.map +1 -0
- package/lib/http/HttpLlm.d.ts +130 -0
- package/lib/http/HttpLlm.js +124 -0
- package/lib/http/HttpLlm.js.map +1 -0
- package/lib/http/HttpLlm.mjs +123 -0
- package/lib/http/HttpLlm.mjs.map +1 -0
- package/lib/http/HttpMigration.d.ts +58 -0
- package/lib/http/HttpMigration.js +52 -0
- package/lib/http/HttpMigration.js.map +1 -0
- package/lib/http/HttpMigration.mjs +52 -0
- package/lib/http/HttpMigration.mjs.map +1 -0
- package/lib/http/index.d.ts +3 -0
- package/lib/http/index.js +20 -0
- package/lib/http/index.js.map +1 -0
- package/lib/http/index.mjs +4 -0
- package/lib/http/index.mjs.map +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.d.ts +8 -0
- package/lib/http/internal/HttpLlmApplicationComposer.js +254 -0
- package/lib/http/internal/HttpLlmApplicationComposer.js.map +1 -0
- package/lib/http/internal/HttpLlmApplicationComposer.mjs +256 -0
- package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.d.ts +6 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.js +24 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.js.map +1 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs +24 -0
- package/lib/http/internal/HttpLlmFunctionFetcher.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.d.ts +4 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.js +45 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.js.map +1 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs +47 -0
- package/lib/http/internal/HttpMigrateApplicationComposer.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.d.ts +4 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.js +107 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs +106 -0
- package/lib/http/internal/HttpMigrateRouteAccessor.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteComposer.d.ts +11 -0
- package/lib/http/internal/HttpMigrateRouteComposer.js +398 -0
- package/lib/http/internal/HttpMigrateRouteComposer.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteComposer.mjs +392 -0
- package/lib/http/internal/HttpMigrateRouteComposer.mjs.map +1 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.d.ts +6 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.js +179 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.js.map +1 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs +174 -0
- package/lib/http/internal/HttpMigrateRouteFetcher.mjs.map +1 -0
- package/lib/http/internal/LlmDataMerger.d.ts +48 -0
- package/lib/http/internal/LlmDataMerger.js +60 -0
- package/lib/http/internal/LlmDataMerger.js.map +1 -0
- package/lib/http/internal/LlmDataMerger.mjs +59 -0
- package/lib/http/internal/LlmDataMerger.mjs.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +20 -0
- package/lib/index.mjs.map +1 -0
- package/lib/utils/ArrayUtil.d.ts +1 -0
- package/lib/utils/ArrayUtil.js +29 -0
- package/lib/utils/ArrayUtil.js.map +1 -0
- package/lib/utils/ArrayUtil.mjs +28 -0
- package/lib/utils/ArrayUtil.mjs.map +1 -0
- package/lib/utils/MapUtil.d.ts +1 -0
- package/lib/utils/MapUtil.js +16 -0
- package/lib/utils/MapUtil.js.map +1 -0
- package/lib/utils/MapUtil.mjs +15 -0
- package/lib/utils/MapUtil.mjs.map +1 -0
- package/lib/utils/NamingConvention.d.ts +68 -0
- package/lib/utils/NamingConvention.js +199 -0
- package/lib/utils/NamingConvention.js.map +1 -0
- package/lib/utils/NamingConvention.mjs +198 -0
- package/lib/utils/NamingConvention.mjs.map +1 -0
- package/lib/utils/Singleton.d.ts +1 -0
- package/lib/utils/Singleton.js +18 -0
- package/lib/utils/Singleton.js.map +1 -0
- package/lib/utils/Singleton.mjs +18 -0
- package/lib/utils/Singleton.mjs.map +1 -0
- package/lib/utils/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil.js +17 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/lib/utils/StringUtil.mjs +13 -0
- package/lib/utils/StringUtil.mjs.map +1 -0
- package/lib/utils/dedent.d.ts +12 -0
- package/lib/utils/dedent.js +51 -0
- package/lib/utils/dedent.js.map +1 -0
- package/lib/utils/dedent.mjs +50 -0
- package/lib/utils/dedent.mjs.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.js +24 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/index.mjs +8 -0
- package/lib/utils/index.mjs.map +1 -0
- package/lib/utils/internal/EndpointUtil.d.ts +8 -0
- package/lib/utils/internal/EndpointUtil.js +37 -0
- package/lib/utils/internal/EndpointUtil.js.map +1 -0
- package/lib/utils/internal/EndpointUtil.mjs +37 -0
- package/lib/utils/internal/EndpointUtil.mjs.map +1 -0
- package/lib/utils/internal/JsonDescriptor.d.ts +10 -0
- package/lib/utils/internal/JsonDescriptor.js +58 -0
- package/lib/utils/internal/JsonDescriptor.js.map +1 -0
- package/lib/utils/internal/JsonDescriptor.mjs +48 -0
- package/lib/utils/internal/JsonDescriptor.mjs.map +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.d.ts +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.js +520 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.js.map +1 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs +584 -0
- package/lib/utils/internal/OpenApiTypeCheckerBase.mjs.map +1 -0
- package/lib/utils/stringifyValidationFailure.d.ts +25 -0
- package/lib/utils/stringifyValidationFailure.js +326 -0
- package/lib/utils/stringifyValidationFailure.js.map +1 -0
- package/lib/utils/stringifyValidationFailure.mjs +325 -0
- package/lib/utils/stringifyValidationFailure.mjs.map +1 -0
- package/lib/validators/LlmTypeChecker.d.ts +117 -0
- package/lib/validators/LlmTypeChecker.js +309 -0
- package/lib/validators/LlmTypeChecker.js.map +1 -0
- package/lib/validators/LlmTypeChecker.mjs +300 -0
- package/lib/validators/LlmTypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiTypeChecker.d.ts +211 -0
- package/lib/validators/OpenApiTypeChecker.js +207 -0
- package/lib/validators/OpenApiTypeChecker.js.map +1 -0
- package/lib/validators/OpenApiTypeChecker.mjs +218 -0
- package/lib/validators/OpenApiTypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiV3TypeChecker.d.ts +26 -0
- package/lib/validators/OpenApiV3TypeChecker.js +30 -0
- package/lib/validators/OpenApiV3TypeChecker.js.map +1 -0
- package/lib/validators/OpenApiV3TypeChecker.mjs +29 -0
- package/lib/validators/OpenApiV3TypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiV3_1TypeChecker.d.ts +29 -0
- package/lib/validators/OpenApiV3_1TypeChecker.js +34 -0
- package/lib/validators/OpenApiV3_1TypeChecker.js.map +1 -0
- package/lib/validators/OpenApiV3_1TypeChecker.mjs +33 -0
- package/lib/validators/OpenApiV3_1TypeChecker.mjs.map +1 -0
- package/lib/validators/OpenApiValidator.d.ts +36 -0
- package/lib/validators/OpenApiValidator.js +71 -0
- package/lib/validators/OpenApiValidator.js.map +1 -0
- package/lib/validators/OpenApiValidator.mjs +75 -0
- package/lib/validators/OpenApiValidator.mjs.map +1 -0
- package/lib/validators/SwaggerV2TypeChecker.d.ts +27 -0
- package/lib/validators/SwaggerV2TypeChecker.js +31 -0
- package/lib/validators/SwaggerV2TypeChecker.js.map +1 -0
- package/lib/validators/SwaggerV2TypeChecker.mjs +30 -0
- package/lib/validators/SwaggerV2TypeChecker.mjs.map +1 -0
- package/lib/validators/functional/_isBigintString.d.ts +1 -0
- package/lib/validators/functional/_isBigintString.js +14 -0
- package/lib/validators/functional/_isBigintString.js.map +1 -0
- package/lib/validators/functional/_isBigintString.mjs +12 -0
- package/lib/validators/functional/_isBigintString.mjs.map +1 -0
- package/lib/validators/functional/_isFormatByte.d.ts +1 -0
- package/lib/validators/functional/_isFormatByte.js +10 -0
- package/lib/validators/functional/_isFormatByte.js.map +1 -0
- package/lib/validators/functional/_isFormatByte.mjs +8 -0
- package/lib/validators/functional/_isFormatByte.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDate.d.ts +1 -0
- package/lib/validators/functional/_isFormatDate.js +7 -0
- package/lib/validators/functional/_isFormatDate.js.map +1 -0
- package/lib/validators/functional/_isFormatDate.mjs +5 -0
- package/lib/validators/functional/_isFormatDate.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDateTime.d.ts +1 -0
- package/lib/validators/functional/_isFormatDateTime.js +7 -0
- package/lib/validators/functional/_isFormatDateTime.js.map +1 -0
- package/lib/validators/functional/_isFormatDateTime.mjs +5 -0
- package/lib/validators/functional/_isFormatDateTime.mjs.map +1 -0
- package/lib/validators/functional/_isFormatDuration.d.ts +1 -0
- package/lib/validators/functional/_isFormatDuration.js +7 -0
- package/lib/validators/functional/_isFormatDuration.js.map +1 -0
- package/lib/validators/functional/_isFormatDuration.mjs +5 -0
- package/lib/validators/functional/_isFormatDuration.mjs.map +1 -0
- package/lib/validators/functional/_isFormatEmail.d.ts +1 -0
- package/lib/validators/functional/_isFormatEmail.js +7 -0
- package/lib/validators/functional/_isFormatEmail.js.map +1 -0
- package/lib/validators/functional/_isFormatEmail.mjs +5 -0
- package/lib/validators/functional/_isFormatEmail.mjs.map +1 -0
- package/lib/validators/functional/_isFormatHostname.d.ts +1 -0
- package/lib/validators/functional/_isFormatHostname.js +7 -0
- package/lib/validators/functional/_isFormatHostname.js.map +1 -0
- package/lib/validators/functional/_isFormatHostname.mjs +5 -0
- package/lib/validators/functional/_isFormatHostname.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.d.ts +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.js +7 -0
- package/lib/validators/functional/_isFormatIdnEmail.js.map +1 -0
- package/lib/validators/functional/_isFormatIdnEmail.mjs +5 -0
- package/lib/validators/functional/_isFormatIdnEmail.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.d.ts +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.js +7 -0
- package/lib/validators/functional/_isFormatIdnHostname.js.map +1 -0
- package/lib/validators/functional/_isFormatIdnHostname.mjs +5 -0
- package/lib/validators/functional/_isFormatIdnHostname.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIpv4.d.ts +1 -0
- package/lib/validators/functional/_isFormatIpv4.js +7 -0
- package/lib/validators/functional/_isFormatIpv4.js.map +1 -0
- package/lib/validators/functional/_isFormatIpv4.mjs +5 -0
- package/lib/validators/functional/_isFormatIpv4.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIpv6.d.ts +1 -0
- package/lib/validators/functional/_isFormatIpv6.js +7 -0
- package/lib/validators/functional/_isFormatIpv6.js.map +1 -0
- package/lib/validators/functional/_isFormatIpv6.mjs +5 -0
- package/lib/validators/functional/_isFormatIpv6.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIri.d.ts +1 -0
- package/lib/validators/functional/_isFormatIri.js +7 -0
- package/lib/validators/functional/_isFormatIri.js.map +1 -0
- package/lib/validators/functional/_isFormatIri.mjs +5 -0
- package/lib/validators/functional/_isFormatIri.mjs.map +1 -0
- package/lib/validators/functional/_isFormatIriReference.d.ts +1 -0
- package/lib/validators/functional/_isFormatIriReference.js +7 -0
- package/lib/validators/functional/_isFormatIriReference.js.map +1 -0
- package/lib/validators/functional/_isFormatIriReference.mjs +5 -0
- package/lib/validators/functional/_isFormatIriReference.mjs.map +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.d.ts +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.js +7 -0
- package/lib/validators/functional/_isFormatJsonPointer.js.map +1 -0
- package/lib/validators/functional/_isFormatJsonPointer.mjs +5 -0
- package/lib/validators/functional/_isFormatJsonPointer.mjs.map +1 -0
- package/lib/validators/functional/_isFormatPassword.d.ts +1 -0
- package/lib/validators/functional/_isFormatPassword.js +6 -0
- package/lib/validators/functional/_isFormatPassword.js.map +1 -0
- package/lib/validators/functional/_isFormatPassword.mjs +4 -0
- package/lib/validators/functional/_isFormatPassword.mjs.map +1 -0
- package/lib/validators/functional/_isFormatRegex.d.ts +1 -0
- package/lib/validators/functional/_isFormatRegex.js +14 -0
- package/lib/validators/functional/_isFormatRegex.js.map +1 -0
- package/lib/validators/functional/_isFormatRegex.mjs +12 -0
- package/lib/validators/functional/_isFormatRegex.mjs.map +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.d.ts +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.js +7 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.js.map +1 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs +5 -0
- package/lib/validators/functional/_isFormatRelativeJsonPointer.mjs.map +1 -0
- package/lib/validators/functional/_isFormatTime.d.ts +1 -0
- package/lib/validators/functional/_isFormatTime.js +7 -0
- package/lib/validators/functional/_isFormatTime.js.map +1 -0
- package/lib/validators/functional/_isFormatTime.mjs +5 -0
- package/lib/validators/functional/_isFormatTime.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUri.d.ts +1 -0
- package/lib/validators/functional/_isFormatUri.js +8 -0
- package/lib/validators/functional/_isFormatUri.js.map +1 -0
- package/lib/validators/functional/_isFormatUri.mjs +6 -0
- package/lib/validators/functional/_isFormatUri.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUriReference.d.ts +1 -0
- package/lib/validators/functional/_isFormatUriReference.js +7 -0
- package/lib/validators/functional/_isFormatUriReference.js.map +1 -0
- package/lib/validators/functional/_isFormatUriReference.mjs +5 -0
- package/lib/validators/functional/_isFormatUriReference.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.d.ts +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.js +7 -0
- package/lib/validators/functional/_isFormatUriTemplate.js.map +1 -0
- package/lib/validators/functional/_isFormatUriTemplate.mjs +5 -0
- package/lib/validators/functional/_isFormatUriTemplate.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUrl.d.ts +1 -0
- package/lib/validators/functional/_isFormatUrl.js +7 -0
- package/lib/validators/functional/_isFormatUrl.js.map +1 -0
- package/lib/validators/functional/_isFormatUrl.mjs +5 -0
- package/lib/validators/functional/_isFormatUrl.mjs.map +1 -0
- package/lib/validators/functional/_isFormatUuid.d.ts +1 -0
- package/lib/validators/functional/_isFormatUuid.js +7 -0
- package/lib/validators/functional/_isFormatUuid.js.map +1 -0
- package/lib/validators/functional/_isFormatUuid.mjs +5 -0
- package/lib/validators/functional/_isFormatUuid.mjs.map +1 -0
- package/lib/validators/functional/_isUniqueItems.d.ts +1 -0
- package/lib/validators/functional/_isUniqueItems.js +140 -0
- package/lib/validators/functional/_isUniqueItems.js.map +1 -0
- package/lib/validators/functional/_isUniqueItems.mjs +138 -0
- package/lib/validators/functional/_isUniqueItems.mjs.map +1 -0
- package/lib/validators/index.d.ts +2 -0
- package/lib/validators/index.js +27 -0
- package/lib/validators/index.js.map +1 -0
- package/lib/validators/index.mjs +7 -0
- package/lib/validators/index.mjs.map +1 -0
- package/lib/validators/internal/IOpenApiValidatorContext.d.ts +14 -0
- package/lib/validators/internal/IOpenApiValidatorContext.js +3 -0
- package/lib/validators/internal/IOpenApiValidatorContext.js.map +1 -0
- package/lib/validators/internal/IOpenApiValidatorContext.mjs +2 -0
- package/lib/validators/internal/IOpenApiValidatorContext.mjs.map +1 -0
- package/lib/validators/internal/OpenApiArrayValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiArrayValidator.js +32 -0
- package/lib/validators/internal/OpenApiArrayValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiArrayValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiArrayValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiBooleanValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiBooleanValidator.js +10 -0
- package/lib/validators/internal/OpenApiBooleanValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiBooleanValidator.mjs +9 -0
- package/lib/validators/internal/OpenApiBooleanValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiConstantValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiConstantValidator.js +10 -0
- package/lib/validators/internal/OpenApiConstantValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiConstantValidator.mjs +9 -0
- package/lib/validators/internal/OpenApiConstantValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiIntegerValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiIntegerValidator.js +33 -0
- package/lib/validators/internal/OpenApiIntegerValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiIntegerValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiIntegerValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiNumberValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiNumberValidator.js +33 -0
- package/lib/validators/internal/OpenApiNumberValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiNumberValidator.mjs +47 -0
- package/lib/validators/internal/OpenApiNumberValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiObjectValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiObjectValidator.js +58 -0
- package/lib/validators/internal/OpenApiObjectValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiObjectValidator.mjs +68 -0
- package/lib/validators/internal/OpenApiObjectValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiOneOfValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiOneOfValidator.js +182 -0
- package/lib/validators/internal/OpenApiOneOfValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiOneOfValidator.mjs +206 -0
- package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.d.ts +4 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.js +122 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.js.map +1 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs +121 -0
- package/lib/validators/internal/OpenApiSchemaNamingRule.mjs.map +1 -0
- package/lib/validators/internal/OpenApiStationValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiStationValidator.js +63 -0
- package/lib/validators/internal/OpenApiStationValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiStationValidator.mjs +107 -0
- package/lib/validators/internal/OpenApiStationValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiStringValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiStringValidator.js +73 -0
- package/lib/validators/internal/OpenApiStringValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiStringValidator.mjs +85 -0
- package/lib/validators/internal/OpenApiStringValidator.mjs.map +1 -0
- package/lib/validators/internal/OpenApiTupleValidator.d.ts +5 -0
- package/lib/validators/internal/OpenApiTupleValidator.js +31 -0
- package/lib/validators/internal/OpenApiTupleValidator.js.map +1 -0
- package/lib/validators/internal/OpenApiTupleValidator.mjs +46 -0
- package/lib/validators/internal/OpenApiTupleValidator.mjs.map +1 -0
- package/package.json +91 -0
- package/src/converters/LlmSchemaConverter.ts +924 -0
- package/src/converters/OpenApiConverter.ts +285 -0
- package/src/converters/index.ts +5 -0
- package/src/converters/internal/LlmDescriptionInverter.ts +178 -0
- package/src/converters/internal/LlmParametersComposer.ts +52 -0
- package/src/converters/internal/OpenApiConstraintShifter.ts +154 -0
- package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -0
- package/src/converters/internal/OpenApiV3Downgrader.ts +355 -0
- package/src/converters/internal/OpenApiV3Upgrader.ts +470 -0
- package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -0
- package/src/converters/internal/SwaggerV2Downgrader.ts +424 -0
- package/src/converters/internal/SwaggerV2Upgrader.ts +523 -0
- package/src/http/HttpError.ts +107 -0
- package/src/http/HttpLlm.ts +210 -0
- package/src/http/HttpMigration.ts +92 -0
- package/src/http/index.ts +3 -0
- package/src/http/internal/HttpLlmApplicationComposer.ts +308 -0
- package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -0
- package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -0
- package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -0
- package/src/http/internal/HttpMigrateRouteComposer.ts +513 -0
- package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -0
- package/src/http/internal/LlmDataMerger.ts +73 -0
- package/src/index.ts +4 -0
- package/src/utils/ArrayUtil.ts +42 -0
- package/src/utils/MapUtil.ts +15 -0
- package/src/utils/NamingConvention.ts +205 -0
- package/src/utils/Singleton.ts +17 -0
- package/src/utils/StringUtil.ts +14 -0
- package/src/utils/dedent.ts +57 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/internal/EndpointUtil.ts +44 -0
- package/src/utils/internal/JsonDescriptor.ts +70 -0
- package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -0
- package/src/utils/stringifyValidationFailure.ts +415 -0
- package/src/validators/LlmTypeChecker.ts +402 -0
- package/src/validators/OpenApiTypeChecker.ts +297 -0
- package/src/validators/OpenApiV3TypeChecker.ts +70 -0
- package/src/validators/OpenApiV3_1TypeChecker.ts +86 -0
- package/src/validators/OpenApiValidator.ts +94 -0
- package/src/validators/SwaggerV2TypeChecker.ts +71 -0
- package/src/validators/functional/_isBigintString.ts +8 -0
- package/src/validators/functional/_isFormatByte.ts +7 -0
- package/src/validators/functional/_isFormatDate.ts +3 -0
- package/src/validators/functional/_isFormatDateTime.ts +4 -0
- package/src/validators/functional/_isFormatDuration.ts +4 -0
- package/src/validators/functional/_isFormatEmail.ts +4 -0
- package/src/validators/functional/_isFormatHostname.ts +4 -0
- package/src/validators/functional/_isFormatIdnEmail.ts +4 -0
- package/src/validators/functional/_isFormatIdnHostname.ts +4 -0
- package/src/validators/functional/_isFormatIpv4.ts +4 -0
- package/src/validators/functional/_isFormatIpv6.ts +4 -0
- package/src/validators/functional/_isFormatIri.ts +3 -0
- package/src/validators/functional/_isFormatIriReference.ts +4 -0
- package/src/validators/functional/_isFormatJsonPointer.ts +3 -0
- package/src/validators/functional/_isFormatPassword.ts +1 -0
- package/src/validators/functional/_isFormatRegex.ts +8 -0
- package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -0
- package/src/validators/functional/_isFormatTime.ts +4 -0
- package/src/validators/functional/_isFormatUri.ts +6 -0
- package/src/validators/functional/_isFormatUriReference.ts +5 -0
- package/src/validators/functional/_isFormatUriTemplate.ts +4 -0
- package/src/validators/functional/_isFormatUrl.ts +4 -0
- package/src/validators/functional/_isFormatUuid.ts +3 -0
- package/src/validators/functional/_isUniqueItems.ts +159 -0
- package/src/validators/index.ts +14 -0
- package/src/validators/internal/IOpenApiValidatorContext.ts +17 -0
- package/src/validators/internal/OpenApiArrayValidator.ts +49 -0
- package/src/validators/internal/OpenApiBooleanValidator.ts +11 -0
- package/src/validators/internal/OpenApiConstantValidator.ts +11 -0
- package/src/validators/internal/OpenApiIntegerValidator.ts +49 -0
- package/src/validators/internal/OpenApiNumberValidator.ts +48 -0
- package/src/validators/internal/OpenApiObjectValidator.ts +83 -0
- package/src/validators/internal/OpenApiOneOfValidator.ts +309 -0
- package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -0
- package/src/validators/internal/OpenApiStationValidator.ts +115 -0
- package/src/validators/internal/OpenApiStringValidator.ts +88 -0
- package/src/validators/internal/OpenApiTupleValidator.ts +55 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { _isUniqueItems } from "../functional/_isUniqueItems";
|
|
4
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
5
|
+
import { OpenApiStationValidator } from "./OpenApiStationValidator";
|
|
6
|
+
|
|
7
|
+
export namespace OpenApiArrayValidator {
|
|
8
|
+
export const validate = (
|
|
9
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IArray>,
|
|
10
|
+
): boolean => {
|
|
11
|
+
if (Array.isArray(ctx.value) === false) return ctx.report(ctx);
|
|
12
|
+
return [
|
|
13
|
+
ctx.value
|
|
14
|
+
.map((value, i) =>
|
|
15
|
+
OpenApiStationValidator.validate({
|
|
16
|
+
...ctx,
|
|
17
|
+
schema: ctx.schema.items,
|
|
18
|
+
value,
|
|
19
|
+
path: `${ctx.path}[${i}]`,
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
.every((v) => v),
|
|
24
|
+
ctx.schema.minItems !== undefined
|
|
25
|
+
? ctx.value.length >= ctx.schema.minItems ||
|
|
26
|
+
ctx.report({
|
|
27
|
+
...ctx,
|
|
28
|
+
expected: `Array<> & MinItems<${ctx.schema.minItems}>`,
|
|
29
|
+
})
|
|
30
|
+
: true,
|
|
31
|
+
ctx.schema.maxItems !== undefined
|
|
32
|
+
? ctx.value.length <= ctx.schema.maxItems ||
|
|
33
|
+
ctx.report({
|
|
34
|
+
...ctx,
|
|
35
|
+
expected: `Array<> & MaxItems<${ctx.schema.maxItems}>`,
|
|
36
|
+
})
|
|
37
|
+
: true,
|
|
38
|
+
ctx.schema.uniqueItems !== undefined
|
|
39
|
+
? ctx.schema.uniqueItems
|
|
40
|
+
? _isUniqueItems(ctx.value) ||
|
|
41
|
+
ctx.report({
|
|
42
|
+
...ctx,
|
|
43
|
+
expected: `Array<> & UniqueItems`,
|
|
44
|
+
})
|
|
45
|
+
: true
|
|
46
|
+
: true,
|
|
47
|
+
].every((v) => v);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiBooleanValidator {
|
|
6
|
+
export const validate = (
|
|
7
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IBoolean>,
|
|
8
|
+
): boolean => {
|
|
9
|
+
return typeof ctx.value === "boolean" || ctx.report(ctx);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiConstantValidator {
|
|
6
|
+
export const validate = (
|
|
7
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IConstant>,
|
|
8
|
+
): boolean => {
|
|
9
|
+
return ctx.value === ctx.schema.const || ctx.report(ctx);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiIntegerValidator {
|
|
6
|
+
export const validate = (
|
|
7
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IInteger>,
|
|
8
|
+
): boolean => {
|
|
9
|
+
if (typeof ctx.value !== "number" || Math.floor(ctx.value) !== ctx.value)
|
|
10
|
+
return ctx.report(ctx);
|
|
11
|
+
return [
|
|
12
|
+
ctx.schema.minimum !== undefined
|
|
13
|
+
? ctx.value >= ctx.schema.minimum ||
|
|
14
|
+
ctx.report({
|
|
15
|
+
...ctx,
|
|
16
|
+
expected: `number & Type<"int32"> & Minimum<${ctx.schema.minimum}>`,
|
|
17
|
+
})
|
|
18
|
+
: true,
|
|
19
|
+
ctx.schema.maximum !== undefined
|
|
20
|
+
? ctx.value <= ctx.schema.maximum ||
|
|
21
|
+
ctx.report({
|
|
22
|
+
...ctx,
|
|
23
|
+
expected: `number & Type<"int32"> & Maximum<${ctx.schema.maximum}>`,
|
|
24
|
+
})
|
|
25
|
+
: true,
|
|
26
|
+
ctx.schema.exclusiveMinimum !== undefined
|
|
27
|
+
? ctx.value > ctx.schema.exclusiveMinimum ||
|
|
28
|
+
ctx.report({
|
|
29
|
+
...ctx,
|
|
30
|
+
expected: `number & Type<"int32"> & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
|
|
31
|
+
})
|
|
32
|
+
: true,
|
|
33
|
+
ctx.schema.exclusiveMaximum !== undefined
|
|
34
|
+
? ctx.value < ctx.schema.exclusiveMaximum ||
|
|
35
|
+
ctx.report({
|
|
36
|
+
...ctx,
|
|
37
|
+
expected: `number & Type<"int32"> & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
|
|
38
|
+
})
|
|
39
|
+
: true,
|
|
40
|
+
ctx.schema.multipleOf !== undefined
|
|
41
|
+
? ctx.value % ctx.schema.multipleOf === 0 ||
|
|
42
|
+
ctx.report({
|
|
43
|
+
...ctx,
|
|
44
|
+
expected: `number & Type<"int32"> & MultipleOf<${ctx.schema.multipleOf}>`,
|
|
45
|
+
})
|
|
46
|
+
: true,
|
|
47
|
+
].every((v) => v);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiNumberValidator {
|
|
6
|
+
export const validate = (
|
|
7
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.INumber>,
|
|
8
|
+
): boolean => {
|
|
9
|
+
if (typeof ctx.value !== "number") return ctx.report(ctx);
|
|
10
|
+
return [
|
|
11
|
+
ctx.schema.minimum !== undefined
|
|
12
|
+
? ctx.value >= ctx.schema.minimum ||
|
|
13
|
+
ctx.report({
|
|
14
|
+
...ctx,
|
|
15
|
+
expected: `number & Minimum<${ctx.schema.minimum}>`,
|
|
16
|
+
})
|
|
17
|
+
: true,
|
|
18
|
+
ctx.schema.maximum !== undefined
|
|
19
|
+
? ctx.value <= ctx.schema.maximum ||
|
|
20
|
+
ctx.report({
|
|
21
|
+
...ctx,
|
|
22
|
+
expected: `number & Maximum<${ctx.schema.maximum}>`,
|
|
23
|
+
})
|
|
24
|
+
: true,
|
|
25
|
+
ctx.schema.exclusiveMinimum !== undefined
|
|
26
|
+
? ctx.value > ctx.schema.exclusiveMinimum ||
|
|
27
|
+
ctx.report({
|
|
28
|
+
...ctx,
|
|
29
|
+
expected: `number & ExclusiveMinimum<${ctx.schema.exclusiveMinimum}>`,
|
|
30
|
+
})
|
|
31
|
+
: true,
|
|
32
|
+
ctx.schema.exclusiveMaximum !== undefined
|
|
33
|
+
? ctx.value < ctx.schema.exclusiveMaximum ||
|
|
34
|
+
ctx.report({
|
|
35
|
+
...ctx,
|
|
36
|
+
expected: `number & ExclusiveMaximum<${ctx.schema.exclusiveMaximum}>`,
|
|
37
|
+
})
|
|
38
|
+
: true,
|
|
39
|
+
ctx.schema.multipleOf !== undefined
|
|
40
|
+
? ctx.value % ctx.schema.multipleOf === 0 ||
|
|
41
|
+
ctx.report({
|
|
42
|
+
...ctx,
|
|
43
|
+
expected: `number & MultipleOf<${ctx.schema.multipleOf}>`,
|
|
44
|
+
})
|
|
45
|
+
: true,
|
|
46
|
+
].every((v) => v);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { NamingConvention } from "../../utils/NamingConvention";
|
|
4
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
5
|
+
import { OpenApiStationValidator } from "./OpenApiStationValidator";
|
|
6
|
+
|
|
7
|
+
export namespace OpenApiObjectValidator {
|
|
8
|
+
export const validate = (
|
|
9
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
|
|
10
|
+
): boolean => {
|
|
11
|
+
if (typeof ctx.value !== "object" || ctx.value === null)
|
|
12
|
+
return ctx.report(ctx);
|
|
13
|
+
return [
|
|
14
|
+
...Object.entries(ctx.schema.properties ?? {}).map(([key, value]) =>
|
|
15
|
+
OpenApiStationValidator.validate({
|
|
16
|
+
...ctx,
|
|
17
|
+
schema: value,
|
|
18
|
+
value: (ctx.value as Record<string, any>)[key],
|
|
19
|
+
path:
|
|
20
|
+
ctx.path +
|
|
21
|
+
(NamingConvention.variable(key)
|
|
22
|
+
? `.${key}`
|
|
23
|
+
: `[${JSON.stringify(key)}]`),
|
|
24
|
+
required: ctx.schema.required?.includes(key) ?? false,
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
...(typeof ctx.schema.additionalProperties === "object" &&
|
|
28
|
+
ctx.schema.additionalProperties !== null
|
|
29
|
+
? Object.entries(ctx.value)
|
|
30
|
+
.filter(
|
|
31
|
+
([key]) =>
|
|
32
|
+
Object.keys(ctx.schema.properties ?? {}).includes(key) ===
|
|
33
|
+
false,
|
|
34
|
+
)
|
|
35
|
+
.map(([key, value]) =>
|
|
36
|
+
OpenApiStationValidator.validate({
|
|
37
|
+
...ctx,
|
|
38
|
+
schema: ctx.schema.additionalProperties as OpenApi.IJsonSchema,
|
|
39
|
+
value,
|
|
40
|
+
path:
|
|
41
|
+
ctx.path +
|
|
42
|
+
(NamingConvention.variable(key)
|
|
43
|
+
? `.${key}`
|
|
44
|
+
: `[${JSON.stringify(key)}]`),
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
: []),
|
|
49
|
+
...(ctx.equals === true &&
|
|
50
|
+
(ctx.schema.additionalProperties ?? false) === false
|
|
51
|
+
? [validateEquals(ctx)]
|
|
52
|
+
: []),
|
|
53
|
+
].every((v) => v);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const validateEquals = (
|
|
57
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IObject>,
|
|
58
|
+
): boolean => {
|
|
59
|
+
const regular: Set<string> = new Set(
|
|
60
|
+
Object.keys(ctx.schema.properties ?? {}),
|
|
61
|
+
);
|
|
62
|
+
return Object.entries(ctx.value as object)
|
|
63
|
+
.map(([key, value]) => {
|
|
64
|
+
if (regular.has(key) === true) return true;
|
|
65
|
+
return ctx.report({
|
|
66
|
+
...ctx,
|
|
67
|
+
path:
|
|
68
|
+
ctx.path +
|
|
69
|
+
(NamingConvention.variable(key)
|
|
70
|
+
? `.${key}`
|
|
71
|
+
: `[${JSON.stringify(key)}]`),
|
|
72
|
+
value,
|
|
73
|
+
expected: "undefined",
|
|
74
|
+
description: [
|
|
75
|
+
`The property \`${key}\` is not defined in the object type.`,
|
|
76
|
+
"",
|
|
77
|
+
"Please remove the property next time.",
|
|
78
|
+
].join("\n"),
|
|
79
|
+
});
|
|
80
|
+
})
|
|
81
|
+
.every((v) => v);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { MapUtil } from "../../utils";
|
|
4
|
+
import { OpenApiTypeChecker } from "../OpenApiTypeChecker";
|
|
5
|
+
import { IOpenApiValidatorContext } from "./IOpenApiValidatorContext";
|
|
6
|
+
import { OpenApiStationValidator } from "./OpenApiStationValidator";
|
|
7
|
+
|
|
8
|
+
export namespace OpenApiOneOfValidator {
|
|
9
|
+
export const validate = (
|
|
10
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IOneOf>,
|
|
11
|
+
): boolean => {
|
|
12
|
+
const discriminator: IDiscriminator = getDiscriminator(ctx);
|
|
13
|
+
for (const item of discriminator.branches)
|
|
14
|
+
if (item.predicator(ctx.value))
|
|
15
|
+
return OpenApiStationValidator.validate({
|
|
16
|
+
...ctx,
|
|
17
|
+
schema: item.schema,
|
|
18
|
+
});
|
|
19
|
+
if (discriminator.branches.length !== 0)
|
|
20
|
+
return validate({
|
|
21
|
+
...ctx,
|
|
22
|
+
schema: {
|
|
23
|
+
oneOf: discriminator.remainders,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const matched: OpenApi.IJsonSchema | undefined =
|
|
27
|
+
discriminator.remainders.find(
|
|
28
|
+
(schema) =>
|
|
29
|
+
OpenApiStationValidator.validate({
|
|
30
|
+
...ctx,
|
|
31
|
+
schema,
|
|
32
|
+
exceptionable: false,
|
|
33
|
+
equals: false,
|
|
34
|
+
}) === true,
|
|
35
|
+
);
|
|
36
|
+
if (matched === undefined) return ctx.report(ctx);
|
|
37
|
+
return ctx.equals === true
|
|
38
|
+
? OpenApiStationValidator.validate({
|
|
39
|
+
...ctx,
|
|
40
|
+
schema: matched,
|
|
41
|
+
})
|
|
42
|
+
: true;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getDiscriminator = (
|
|
46
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IOneOf>,
|
|
47
|
+
): IDiscriminator => {
|
|
48
|
+
const resolvedList: IFlatSchema[] = ctx.schema.oneOf.map((schema) =>
|
|
49
|
+
getFlattened({
|
|
50
|
+
components: ctx.components,
|
|
51
|
+
schema,
|
|
52
|
+
visited: new Set(),
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// FIND ANY TYPE
|
|
57
|
+
const anything: IFlatSchema | undefined = resolvedList.find((resolved) =>
|
|
58
|
+
OpenApiTypeChecker.isUnknown(resolved.escaped),
|
|
59
|
+
);
|
|
60
|
+
if (anything)
|
|
61
|
+
return {
|
|
62
|
+
branches: [],
|
|
63
|
+
remainders: [anything.schema],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// CHECK NULLABLES
|
|
67
|
+
const nullables: IFlatSchema<OpenApi.IJsonSchema.INull>[] =
|
|
68
|
+
resolvedList.filter(
|
|
69
|
+
(resolved): resolved is IFlatSchema<OpenApi.IJsonSchema.INull> =>
|
|
70
|
+
OpenApiTypeChecker.isNull(resolved.schema),
|
|
71
|
+
);
|
|
72
|
+
const significant: IFlatSchema<OpenApi.IJsonSchema>[] = resolvedList.filter(
|
|
73
|
+
(resolved) => false === OpenApiTypeChecker.isNull(resolved.escaped),
|
|
74
|
+
);
|
|
75
|
+
if (significant.length === 1)
|
|
76
|
+
return {
|
|
77
|
+
branches: [
|
|
78
|
+
{
|
|
79
|
+
schema: significant[0]!.schema,
|
|
80
|
+
predicator: (value) => value !== null,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
remainders: nullables.map((nullable) => nullable.schema),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// DISCRIMINATIONS
|
|
87
|
+
const tuples = significant.filter((flat) =>
|
|
88
|
+
OpenApiTypeChecker.isTuple(flat.escaped),
|
|
89
|
+
);
|
|
90
|
+
const arrays = significant.filter(
|
|
91
|
+
(flat): flat is IFlatSchema<OpenApi.IJsonSchema.IArray> =>
|
|
92
|
+
OpenApiTypeChecker.isArray(flat.escaped),
|
|
93
|
+
);
|
|
94
|
+
const branches: IDiscriminatorBranch[] = [
|
|
95
|
+
...(tuples.length === 0 && arrays.length !== 0
|
|
96
|
+
? discriminateArrays(
|
|
97
|
+
ctx,
|
|
98
|
+
significant.filter(
|
|
99
|
+
(flat): flat is IFlatSchema<OpenApi.IJsonSchema.IArray> =>
|
|
100
|
+
OpenApiTypeChecker.isArray(flat.schema),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
: []),
|
|
104
|
+
...discriminateObjects(
|
|
105
|
+
ctx,
|
|
106
|
+
significant.filter(
|
|
107
|
+
(flat): flat is IFlatSchema<OpenApi.IJsonSchema.IObject> =>
|
|
108
|
+
OpenApiTypeChecker.isObject(flat.escaped),
|
|
109
|
+
),
|
|
110
|
+
tuples.length + arrays.length === 0,
|
|
111
|
+
),
|
|
112
|
+
];
|
|
113
|
+
return {
|
|
114
|
+
branches,
|
|
115
|
+
remainders: ctx.schema.oneOf.filter(
|
|
116
|
+
(x) => branches.some((y) => y.schema === x) === false,
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const discriminateArrays = (
|
|
122
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IOneOf>,
|
|
123
|
+
arraySchemas: IFlatSchema<OpenApi.IJsonSchema.IArray>[],
|
|
124
|
+
): IDiscriminatorBranch[] => {
|
|
125
|
+
if (arraySchemas.length === 1)
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
schema: arraySchemas[0]!.schema,
|
|
129
|
+
predicator: (value) => Array.isArray(value),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
return arraySchemas
|
|
133
|
+
.filter((flat, i, array) =>
|
|
134
|
+
array.every(
|
|
135
|
+
(item, j) =>
|
|
136
|
+
i === j ||
|
|
137
|
+
OpenApiTypeChecker.covers({
|
|
138
|
+
components: ctx.components,
|
|
139
|
+
x: item.escaped.items,
|
|
140
|
+
y: flat.escaped.items,
|
|
141
|
+
}) === false,
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
.map(
|
|
145
|
+
(flat) =>
|
|
146
|
+
({
|
|
147
|
+
schema: flat.schema,
|
|
148
|
+
predicator: (value) =>
|
|
149
|
+
Array.isArray(value) &&
|
|
150
|
+
(value.length === 0 ||
|
|
151
|
+
OpenApiStationValidator.validate({
|
|
152
|
+
...ctx,
|
|
153
|
+
schema: (flat.escaped as OpenApi.IJsonSchema.IArray).items,
|
|
154
|
+
value: value[0]!,
|
|
155
|
+
path: `${ctx.path}[0]`,
|
|
156
|
+
exceptionable: false,
|
|
157
|
+
equals: false,
|
|
158
|
+
})),
|
|
159
|
+
}) satisfies IDiscriminatorBranch,
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const discriminateObjects = (
|
|
164
|
+
ctx: IOpenApiValidatorContext<OpenApi.IJsonSchema.IOneOf>,
|
|
165
|
+
objectSchemas: IFlatSchema<OpenApi.IJsonSchema.IObject>[],
|
|
166
|
+
noArray: boolean,
|
|
167
|
+
): IDiscriminatorBranch[] => {
|
|
168
|
+
if (objectSchemas.length === 1)
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
schema: objectSchemas[0]!.schema,
|
|
172
|
+
predicator: noArray
|
|
173
|
+
? (value) => typeof value === "object" && value !== null
|
|
174
|
+
: (value) =>
|
|
175
|
+
typeof value === "object" &&
|
|
176
|
+
value !== null &&
|
|
177
|
+
Array.isArray(value) === false,
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
// KEEP ONLY REQUIRED PROPERTIES
|
|
182
|
+
objectSchemas = objectSchemas
|
|
183
|
+
.filter(
|
|
184
|
+
(flat) =>
|
|
185
|
+
flat.escaped.properties !== undefined &&
|
|
186
|
+
flat.escaped.required !== undefined,
|
|
187
|
+
)
|
|
188
|
+
.map(
|
|
189
|
+
(flat) =>
|
|
190
|
+
({
|
|
191
|
+
...flat,
|
|
192
|
+
escaped: {
|
|
193
|
+
...flat.escaped,
|
|
194
|
+
properties: Object.fromEntries(
|
|
195
|
+
Object.entries(flat.escaped.properties ?? {}).map(
|
|
196
|
+
([key, value]) => [
|
|
197
|
+
key,
|
|
198
|
+
getFlattened({
|
|
199
|
+
components: ctx.components,
|
|
200
|
+
schema: value,
|
|
201
|
+
visited: new Set(),
|
|
202
|
+
}).escaped,
|
|
203
|
+
],
|
|
204
|
+
),
|
|
205
|
+
),
|
|
206
|
+
},
|
|
207
|
+
}) satisfies IFlatSchema<OpenApi.IJsonSchema.IObject>,
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
// PROPERTY MATRIX
|
|
211
|
+
const matrix: Map<string, Array<OpenApi.IJsonSchema | null>> = new Map();
|
|
212
|
+
objectSchemas.forEach((obj, i) => {
|
|
213
|
+
for (const [key, value] of Object.entries(obj.escaped.properties ?? {})) {
|
|
214
|
+
if (!!obj.escaped.required?.includes(key) === false) continue;
|
|
215
|
+
MapUtil.take(matrix, key, () =>
|
|
216
|
+
new Array(objectSchemas.length).fill(null),
|
|
217
|
+
)[i] = value;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// THE BRANCHES
|
|
222
|
+
return objectSchemas
|
|
223
|
+
.map((obj, i) => {
|
|
224
|
+
const candidates: string[] = [];
|
|
225
|
+
for (const [key, value] of Object.entries(
|
|
226
|
+
obj.escaped.properties ?? {},
|
|
227
|
+
)) {
|
|
228
|
+
if (!!obj.escaped.required?.includes(key) === false) continue;
|
|
229
|
+
|
|
230
|
+
const neighbors: OpenApi.IJsonSchema[] = matrix
|
|
231
|
+
.get(key)!
|
|
232
|
+
.filter((_oppo, j) => i !== j)
|
|
233
|
+
.filter((oppo) => oppo !== null);
|
|
234
|
+
const unique: boolean = OpenApiTypeChecker.isConstant(value)
|
|
235
|
+
? neighbors.every(
|
|
236
|
+
(oppo) =>
|
|
237
|
+
OpenApiTypeChecker.isConstant(oppo) &&
|
|
238
|
+
value.const !== oppo.const,
|
|
239
|
+
)
|
|
240
|
+
: neighbors.length === 0;
|
|
241
|
+
if (unique) candidates.push(key);
|
|
242
|
+
}
|
|
243
|
+
if (candidates.length === 0) return null;
|
|
244
|
+
const top: string =
|
|
245
|
+
candidates.find((key) =>
|
|
246
|
+
OpenApiTypeChecker.isConstant(obj.escaped.properties![key]!),
|
|
247
|
+
) ?? candidates[0]!;
|
|
248
|
+
const target: OpenApi.IJsonSchema = obj.escaped.properties![top]!;
|
|
249
|
+
return {
|
|
250
|
+
schema: obj.schema,
|
|
251
|
+
predicator: OpenApiTypeChecker.isConstant(target)
|
|
252
|
+
? (value) =>
|
|
253
|
+
typeof value === "object" &&
|
|
254
|
+
value !== null &&
|
|
255
|
+
(value as any)[top] === target.const
|
|
256
|
+
: (value) =>
|
|
257
|
+
typeof value === "object" &&
|
|
258
|
+
value !== null &&
|
|
259
|
+
(value as any)[top] !== undefined,
|
|
260
|
+
} satisfies IDiscriminatorBranch;
|
|
261
|
+
})
|
|
262
|
+
.filter((b) => b !== null);
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const getFlattened = (props: {
|
|
267
|
+
components: OpenApi.IComponents;
|
|
268
|
+
schema: OpenApi.IJsonSchema;
|
|
269
|
+
visited: Set<string>;
|
|
270
|
+
}): IFlatSchema => {
|
|
271
|
+
if (OpenApiTypeChecker.isReference(props.schema)) {
|
|
272
|
+
const key: string = props.schema.$ref.split("/").pop() ?? "";
|
|
273
|
+
if (props.visited.has(key))
|
|
274
|
+
return {
|
|
275
|
+
schema: props.schema,
|
|
276
|
+
escaped: {},
|
|
277
|
+
};
|
|
278
|
+
props.visited.add(key);
|
|
279
|
+
return {
|
|
280
|
+
...getFlattened({
|
|
281
|
+
components: props.components,
|
|
282
|
+
schema: props.components.schemas?.[key] ?? {},
|
|
283
|
+
visited: props.visited,
|
|
284
|
+
}),
|
|
285
|
+
schema: props.schema,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
schema: props.schema,
|
|
290
|
+
escaped: props.schema,
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
interface IDiscriminator {
|
|
295
|
+
branches: IDiscriminatorBranch[];
|
|
296
|
+
remainders: OpenApi.IJsonSchema[];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
interface IDiscriminatorBranch {
|
|
300
|
+
schema: OpenApi.IJsonSchema;
|
|
301
|
+
predicator: (value: unknown) => boolean;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface IFlatSchema<
|
|
305
|
+
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema,
|
|
306
|
+
> {
|
|
307
|
+
schema: OpenApi.IJsonSchema;
|
|
308
|
+
escaped: Schema;
|
|
309
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { OpenApi } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
import { OpenApiTypeChecker } from "../OpenApiTypeChecker";
|
|
4
|
+
|
|
5
|
+
export namespace OpenApiSchemaNamingRule {
|
|
6
|
+
export const getName = (
|
|
7
|
+
schema: OpenApi.IJsonSchema,
|
|
8
|
+
union: boolean = false,
|
|
9
|
+
): string => {
|
|
10
|
+
// COALESCE
|
|
11
|
+
if (OpenApiTypeChecker.isUnknown(schema)) return "unknown";
|
|
12
|
+
else if (OpenApiTypeChecker.isNull(schema)) return "null";
|
|
13
|
+
else if (OpenApiTypeChecker.isOneOf(schema))
|
|
14
|
+
return schema.oneOf.map((child) => getName(child, true)).join(" | ");
|
|
15
|
+
// ATOMICS
|
|
16
|
+
else if (OpenApiTypeChecker.isConstant(schema))
|
|
17
|
+
return JSON.stringify(schema.const);
|
|
18
|
+
else if (OpenApiTypeChecker.isBoolean(schema)) return "boolean";
|
|
19
|
+
else if (OpenApiTypeChecker.isInteger(schema))
|
|
20
|
+
return joinIntersection(getNameOfInteger(schema), union);
|
|
21
|
+
else if (OpenApiTypeChecker.isNumber(schema))
|
|
22
|
+
return joinIntersection(getNameOfNumber(schema), union);
|
|
23
|
+
else if (OpenApiTypeChecker.isString(schema))
|
|
24
|
+
return joinIntersection(getNameOfString(schema), union);
|
|
25
|
+
// INSTANCES
|
|
26
|
+
else if (OpenApiTypeChecker.isReference(schema))
|
|
27
|
+
return schema.$ref.split("/").pop() ?? "unknown";
|
|
28
|
+
else if (OpenApiTypeChecker.isObject(schema)) return "__object";
|
|
29
|
+
else if (OpenApiTypeChecker.isArray(schema))
|
|
30
|
+
return joinIntersection(getNameOfArray(schema), union);
|
|
31
|
+
else if (OpenApiTypeChecker.isTuple(schema)) return getNameOfTuple(schema);
|
|
32
|
+
return "unknown";
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getNameOfInteger = (schema: OpenApi.IJsonSchema.IInteger): string[] => [
|
|
36
|
+
"number",
|
|
37
|
+
...(schema.minimum !== undefined
|
|
38
|
+
? [
|
|
39
|
+
schema.exclusiveMinimum
|
|
40
|
+
? `tags.ExclusiveMinimum<${schema.minimum}>`
|
|
41
|
+
: `tags.Minimum<${schema.minimum}>`,
|
|
42
|
+
]
|
|
43
|
+
: []),
|
|
44
|
+
...(schema.maximum !== undefined
|
|
45
|
+
? [
|
|
46
|
+
schema.exclusiveMaximum
|
|
47
|
+
? `tags.ExclusiveMaximum<${schema.maximum}>`
|
|
48
|
+
: `tags.Maximum<${schema.maximum}>`,
|
|
49
|
+
]
|
|
50
|
+
: []),
|
|
51
|
+
...(schema.multipleOf !== undefined
|
|
52
|
+
? [`tags.MultipleOf<${schema.multipleOf}>`]
|
|
53
|
+
: []),
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const getNameOfNumber = (schema: OpenApi.IJsonSchema.INumber): string[] => [
|
|
57
|
+
"number",
|
|
58
|
+
...(schema.minimum !== undefined
|
|
59
|
+
? [
|
|
60
|
+
schema.exclusiveMinimum
|
|
61
|
+
? `tags.ExclusiveMinimum<${schema.minimum}>`
|
|
62
|
+
: `tags.Minimum<${schema.minimum}>`,
|
|
63
|
+
]
|
|
64
|
+
: []),
|
|
65
|
+
...(schema.maximum !== undefined
|
|
66
|
+
? [
|
|
67
|
+
schema.exclusiveMaximum
|
|
68
|
+
? `tags.ExclusiveMaximum<${schema.maximum}>`
|
|
69
|
+
: `tags.Maximum<${schema.maximum}>`,
|
|
70
|
+
]
|
|
71
|
+
: []),
|
|
72
|
+
...(schema.multipleOf !== undefined
|
|
73
|
+
? [`tags.MultipleOf<${schema.multipleOf}>`]
|
|
74
|
+
: []),
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const getNameOfString = (schema: OpenApi.IJsonSchema.IString): string[] => [
|
|
78
|
+
"string",
|
|
79
|
+
...(schema.format !== undefined
|
|
80
|
+
? [`tags.Format<${JSON.stringify(schema.format)}>`]
|
|
81
|
+
: []),
|
|
82
|
+
...(schema.pattern !== undefined && schema.format === undefined
|
|
83
|
+
? [`tags.Pattern<${JSON.stringify(schema.pattern)}>`]
|
|
84
|
+
: []),
|
|
85
|
+
...(schema.contentMediaType !== undefined
|
|
86
|
+
? [`tags.ContentMediaType<${JSON.stringify(schema.contentMediaType)}>`]
|
|
87
|
+
: []),
|
|
88
|
+
...(schema.minLength !== undefined
|
|
89
|
+
? [`tags.MinLength<${schema.minLength}>`]
|
|
90
|
+
: []),
|
|
91
|
+
...(schema.maxLength !== undefined
|
|
92
|
+
? [`tags.MaxLength<${schema.maxLength}>`]
|
|
93
|
+
: []),
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const getNameOfArray = (schema: OpenApi.IJsonSchema.IArray): string[] => [
|
|
97
|
+
`Array<${getName(schema.items)}>`,
|
|
98
|
+
...(schema.minItems !== undefined
|
|
99
|
+
? [`tags.MinItems<${schema.minItems}>`]
|
|
100
|
+
: []),
|
|
101
|
+
...(schema.maxItems !== undefined
|
|
102
|
+
? [`tags.MaxItems<${schema.maxItems}>`]
|
|
103
|
+
: []),
|
|
104
|
+
...(schema.uniqueItems !== undefined ? [`tags.UniqueItems`] : []),
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
const getNameOfTuple = (schema: OpenApi.IJsonSchema.ITuple): string =>
|
|
108
|
+
"[" +
|
|
109
|
+
[
|
|
110
|
+
...schema.prefixItems.map((child) => getName(child)),
|
|
111
|
+
...(schema.additionalItems === true
|
|
112
|
+
? ["...Array<unknown>"]
|
|
113
|
+
: typeof schema.additionalItems === "object" &&
|
|
114
|
+
schema.additionalItems !== null
|
|
115
|
+
? [`...Array<${getName(schema.additionalItems)}>`]
|
|
116
|
+
: []),
|
|
117
|
+
].join(", ") +
|
|
118
|
+
"]";
|
|
119
|
+
|
|
120
|
+
const joinIntersection = (elements: string[], union: boolean): string => {
|
|
121
|
+
const str: string = elements.join(" & ");
|
|
122
|
+
return union ? `(${str})` : str;
|
|
123
|
+
};
|
|
124
|
+
}
|