diff --git a/packages/core/http/core-http-server/index.ts b/packages/core/http/core-http-server/index.ts index 240dc397e0ad2..de373db4c27de 100644 --- a/packages/core/http/core-http-server/index.ts +++ b/packages/core/http/core-http-server/index.ts @@ -131,9 +131,9 @@ export type { export type { AddVersionOpts, - RequestValidation, - ResponseValidation, - Version, + VersionedRouteRequestValidation, + VersionedRouteResponseValidation, + ApiVersion, VersionedRoute, VersionedRouteConfig, VersionedRouteRegistrar, diff --git a/packages/core/http/core-http-server/src/versioning/index.ts b/packages/core/http/core-http-server/src/versioning/index.ts index c3cdbfa7a10c0..1b2ee09771225 100644 --- a/packages/core/http/core-http-server/src/versioning/index.ts +++ b/packages/core/http/core-http-server/src/versioning/index.ts @@ -7,10 +7,10 @@ */ export type { - Version, + ApiVersion, AddVersionOpts, - RequestValidation, - ResponseValidation, + VersionedRouteRequestValidation, + VersionedRouteResponseValidation, VersionedRoute, VersionedRouteConfig, VersionedRouteRegistrar, diff --git a/packages/core/http/core-http-server/src/versioning/types.ts b/packages/core/http/core-http-server/src/versioning/types.ts index 8f3c3fc516881..bf5eec361018d 100644 --- a/packages/core/http/core-http-server/src/versioning/types.ts +++ b/packages/core/http/core-http-server/src/versioning/types.ts @@ -25,7 +25,7 @@ type RqCtx = RequestHandlerContextBase; * Assuming that version will be a monotonically increasing number where: version > 0. * @experimental */ -export type Version = `${number}`; +export type ApiVersion = `${number}`; /** * Configuration for a versioned route @@ -156,10 +156,10 @@ export interface VersionedRouter { } /** @experimental */ -export type RequestValidation = RouteValidatorFullConfig; +export type VersionedRouteRequestValidation = RouteValidatorFullConfig; /** @experimental */ -export interface ResponseValidation { +export interface VersionedRouteResponseValidation { [statusCode: number]: { body: RouteValidationFunction | Type }; unsafe?: { body?: boolean }; } @@ -173,14 +173,14 @@ interface FullValidationConfig { * Validation to run against route inputs: params, query and body * @experimental */ - request?: RequestValidation; + request?: VersionedRouteRequestValidation; /** * Validation to run against route output * @note This validation is only intended to run in development. Do not use this * for setting default values! * @experimental */ - response?: ResponseValidation; + response?: VersionedRouteResponseValidation; } /** @@ -193,7 +193,7 @@ export interface AddVersionOpts { * Version to assign to this route * @experimental */ - version: Version; + version: ApiVersion; /** * Validation for this version of a route * @experimental diff --git a/packages/core/http/core-http-versioned-router-server-internal/src/core_versioned_route.ts b/packages/core/http/core-http-versioned-router-server-internal/src/core_versioned_route.ts index 5e21cd2dc8b15..fea7e947e2bed 100644 --- a/packages/core/http/core-http-versioned-router-server-internal/src/core_versioned_route.ts +++ b/packages/core/http/core-http-versioned-router-server-internal/src/core_versioned_route.ts @@ -15,7 +15,7 @@ import type { KibanaResponseFactory, } from '@kbn/core-http-server'; import type { - Version, + ApiVersion, AddVersionOpts, VersionedRoute, VersionedRouteConfig, @@ -36,7 +36,7 @@ const passThroughValidation = { body: schema.any(), params: schema.any(), query: export class CoreVersionedRoute implements VersionedRoute { private readonly handlers = new Map< - Version, + ApiVersion, { fn: RequestHandler; options: Options; @@ -85,7 +85,7 @@ export class CoreVersionedRoute implements VersionedRoute { req: KibanaRequest, res: KibanaResponseFactory ) => { - const version = req.headers[VERSION_HEADER] as undefined | Version; + const version = req.headers[VERSION_HEADER] as undefined | ApiVersion; if (!version) { return res.custom({ statusCode: 406,