From a896b647201b7190b0b0d6d65a0e538fe9187246 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 9 Jul 2025 16:42:29 +0400 Subject: [PATCH] Allow containers with a single variant --- compiler/src/steps/validate-model.ts | 15 ++++----------- output/schema/validation-errors.json | 22 ---------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/compiler/src/steps/validate-model.ts b/compiler/src/steps/validate-model.ts index 6c95dbd77c..469a94b79c 100644 --- a/compiler/src/steps/validate-model.ts +++ b/compiler/src/steps/validate-model.ts @@ -579,17 +579,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma if (typeDef.variants?.kind === 'container') { const variants = typeDef.properties.filter(prop => !(prop.containerProperty ?? false)) - if (variants.length === 1) { - // Single-variant containers must have a required property - if (!variants[0].required) { - modelError(`Property ${variants[0].name} is a single-variant and must be required`) - } - } else { - // Multiple variants must all be optional - for (const v of variants) { - if (v.required) { - modelError(`Variant ${variants[0].name} must be optional`) - } + // Variants must all be optional + for (const v of variants) { + if (v.required) { + modelError(`Variant ${variants[0].name} must be optional`) } } } diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index b7074cf928..cc41b3bc2f 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -1,12 +1,5 @@ { "endpointErrors": { - "async_search.submit": { - "request": [ - "interface definition _types:QueryVectorBuilder - Property text_embedding is a single-variant and must be required", - "interface definition _types:RankContainer - Property rrf is a single-variant and must be required" - ], - "response": [] - }, "create": { "request": [ "Request: query parameter 'if_primary_term' does not exist in the json spec", @@ -82,21 +75,6 @@ ], "response": [] }, - "transform.get_transform": { - "request": [], - "response": [ - "interface definition transform._types:RetentionPolicyContainer - Property time is a single-variant and must be required", - "interface definition transform._types:SyncContainer - Property time is a single-variant and must be required" - ] - }, - "watcher.execute_watch": { - "request": [ - "interface definition watcher._types:TriggerContainer - Property schedule is a single-variant and must be required" - ], - "response": [ - "interface definition watcher._types:TriggerEventContainer - Property schedule is a single-variant and must be required" - ] - }, "xpack.info": { "request": [ "request definition xpack.info:Request / query - Property 'human' is already defined in an ancestor class"