From d58702b4ff7e97466a2bd14e51f135e242266c80 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 10 Jul 2025 13:51:40 +0400 Subject: [PATCH] Allow containers with a single variant (#4853) (cherry picked from commit c3e323a4536ee9fa1ed482d30521c0a9f649acfe) # Conflicts: # output/schema/validation-errors.json --- compiler/src/steps/validate-model.ts | 15 ++++----------- output/schema/validation-errors.json | 24 +----------------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/compiler/src/steps/validate-model.ts b/compiler/src/steps/validate-model.ts index 706d2f983c..83e9d79515 100644 --- a/compiler/src/steps/validate-model.ts +++ b/compiler/src/steps/validate-model.ts @@ -584,17 +584,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 a31e730455..722a491ce9 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -2,8 +2,7 @@ "endpointErrors": { "async_search.submit": { "request": [ - "Request: query parameter 'min_compatible_shard_node' does not exist in the json spec", - "interface definition _types:QueryVectorBuilder - Property text_embedding is a single-variant and must be required" + "Request: query parameter 'min_compatible_shard_node' does not exist in the json spec" ], "response": [] }, @@ -281,12 +280,6 @@ ], "response": [] }, - "search": { - "request": [ - "interface definition _types:RankContainer - Property rrf is a single-variant and must be required" - ], - "response": [] - }, "search_mvt": { "request": [ "Request: query parameter 'grid_agg' does not exist in the json spec", @@ -326,21 +319,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"