Skip to content

Allow containers with a single variant #4853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions compiler/src/steps/validate-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
}
}
Expand Down
22 changes: 0 additions & 22 deletions output/schema/validation-errors.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
Loading