diff --git a/x-pack/plugins/ml/server/routes/schemas/modules.ts b/x-pack/plugins/ml/server/routes/schemas/modules.ts index 23148c14c734e..6961966fd2ab8 100644 --- a/x-pack/plugins/ml/server/routes/schemas/modules.ts +++ b/x-pack/plugins/ml/server/routes/schemas/modules.ts @@ -71,19 +71,11 @@ export const setupModuleBodySchema = schema.object({ estimateModelMemory: schema.maybe(schema.boolean()), }); -export const getModuleIdParamSchema = (optional = false) => { - const stringType = schema.string(); - return schema.object({ - /** - * ID of the module. - */ - moduleId: optional ? schema.maybe(stringType) : stringType, - }); -}; - -export const optionalModuleIdParamSchema = getModuleIdParamSchema(true); +export const optionalModuleIdParamSchema = schema.object({ + moduleId: schema.maybe(schema.string()), +}); -export const moduleIdParamSchema = getModuleIdParamSchema(false); +export const moduleIdParamSchema = schema.object({ moduleId: schema.string() }); export const modulesIndexPatternTitleSchema = schema.object({ /** diff --git a/x-pack/plugins/ml/server/shared_services/providers/modules.ts b/x-pack/plugins/ml/server/shared_services/providers/modules.ts index 236db6c34b9d5..27935fd6fe21d 100644 --- a/x-pack/plugins/ml/server/shared_services/providers/modules.ts +++ b/x-pack/plugins/ml/server/shared_services/providers/modules.ts @@ -8,9 +8,10 @@ import { LegacyAPICaller, KibanaRequest, SavedObjectsClientContract } from 'kiba import { TypeOf } from '@kbn/config-schema'; import { DataRecognizer } from '../../models/data_recognizer'; import { SharedServicesChecks } from '../shared_services'; -import { setupModuleBodySchema } from '../../routes/schemas/modules'; +import { moduleIdParamSchema, setupModuleBodySchema } from '../../routes/schemas/modules'; -export type ModuleSetupPayload = { moduleId: string } & TypeOf; +export type ModuleSetupPayload = TypeOf & + TypeOf; export interface ModulesProvider { modulesProvider(