Skip to content

Commit e59fc0c

Browse files
committed
Consider CommonCatQueryParameters to validate query parameters (#3260)
The JSON rest-api-spec generally encodes this parameters, so that reduces the number of validation errors. (cherry picked from commit d9bf86f)
1 parent 4e96fd9 commit e59fc0c

File tree

7 files changed

+156
-188
lines changed

7 files changed

+156
-188
lines changed

compiler/src/steps/validate-rest-spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,30 @@ export default async function validateRestSpec (model: model.Model, jsonSpec: Ma
160160
if (definition.body.kind !== 'no_body') {
161161
body = Body.yesBody
162162
}
163+
164+
if (definition.attachedBehaviors != null) {
165+
for (const attachedBehavior of definition.attachedBehaviors) {
166+
const type_ = getDefinition({
167+
namespace: '_spec_utils',
168+
name: attachedBehavior
169+
})
170+
if (
171+
type_.kind === 'interface' &&
172+
// allowing CommonQueryParameters too generates many errors
173+
attachedBehavior === 'CommonCatQueryParameters'
174+
) {
175+
for (const prop of type_.properties) {
176+
query.push(prop)
177+
}
178+
}
179+
}
180+
}
163181
} else {
164182
if (definition.properties.length > 0) {
165183
query.push(...definition.properties)
166184
}
167185
}
168186

169-
if (Array.isArray(definition.inherits)) {
170-
const inherits = definition.inherits.map(inherit => getDefinition(inherit.type))
171-
for (const inherit of inherits) {
172-
const properties = getProperties(inherit)
173-
if (properties.path.length > 0) {
174-
path.push(...properties.path)
175-
}
176-
177-
if (properties.query.length > 0) {
178-
query.push(...properties.query)
179-
}
180-
181-
if (properties.body === Body.yesBody) {
182-
body = properties.body
183-
}
184-
}
185-
}
186-
187187
return { path, query, body }
188188
}
189189
}

output/openapi/elasticsearch-openapi.json

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema-serverless.json

Lines changed: 36 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 36 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)