Skip to content

Commit 67b5748

Browse files
pquentingithub-actions[bot]
authored andcommitted
Allow containers with a single variant (#4853)
(cherry picked from commit c3e323a)
1 parent d1f7278 commit 67b5748

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

compiler/src/steps/validate-model.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -579,17 +579,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
579579

580580
if (typeDef.variants?.kind === 'container') {
581581
const variants = typeDef.properties.filter(prop => !(prop.containerProperty ?? false))
582-
if (variants.length === 1) {
583-
// Single-variant containers must have a required property
584-
if (!variants[0].required) {
585-
modelError(`Property ${variants[0].name} is a single-variant and must be required`)
586-
}
587-
} else {
588-
// Multiple variants must all be optional
589-
for (const v of variants) {
590-
if (v.required) {
591-
modelError(`Variant ${variants[0].name} must be optional`)
592-
}
582+
// Variants must all be optional
583+
for (const v of variants) {
584+
if (v.required) {
585+
modelError(`Variant ${variants[0].name} must be optional`)
593586
}
594587
}
595588
}

output/schema/validation-errors.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
{
22
"endpointErrors": {
3-
"async_search.submit": {
4-
"request": [
5-
"interface definition _types:QueryVectorBuilder - Property text_embedding is a single-variant and must be required",
6-
"interface definition _types:RankContainer - Property rrf is a single-variant and must be required"
7-
],
8-
"response": []
9-
},
103
"create": {
114
"request": [
125
"Request: query parameter 'if_primary_term' does not exist in the json spec",
@@ -88,21 +81,6 @@
8881
],
8982
"response": []
9083
},
91-
"transform.get_transform": {
92-
"request": [],
93-
"response": [
94-
"interface definition transform._types:RetentionPolicyContainer - Property time is a single-variant and must be required",
95-
"interface definition transform._types:SyncContainer - Property time is a single-variant and must be required"
96-
]
97-
},
98-
"watcher.execute_watch": {
99-
"request": [
100-
"interface definition watcher._types:TriggerContainer - Property schedule is a single-variant and must be required"
101-
],
102-
"response": [
103-
"interface definition watcher._types:TriggerEventContainer - Property schedule is a single-variant and must be required"
104-
]
105-
},
10684
"xpack.info": {
10785
"request": [
10886
"request definition xpack.info:Request / query - Property 'human' is already defined in an ancestor class"

0 commit comments

Comments
 (0)