Skip to content

Commit

Permalink
Consider CommonCatQueryParameters to validate query parameters (#3260) (
Browse files Browse the repository at this point in the history
#3261)

The JSON rest-api-spec generally encodes this parameters, so that
reduces the number of validation errors.

(cherry picked from commit d9bf86f)
  • Loading branch information
pquentin authored Dec 6, 2024
1 parent 4e96fd9 commit 203259f
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 188 deletions.
36 changes: 18 additions & 18 deletions compiler/src/steps/validate-rest-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,30 @@ export default async function validateRestSpec (model: model.Model, jsonSpec: Ma
if (definition.body.kind !== 'no_body') {
body = Body.yesBody
}

if (definition.attachedBehaviors != null) {
for (const attachedBehavior of definition.attachedBehaviors) {
const type_ = getDefinition({
namespace: '_spec_utils',
name: attachedBehavior
})
if (
type_.kind === 'interface' &&
// allowing CommonQueryParameters too generates many errors
attachedBehavior === 'CommonCatQueryParameters'
) {
for (const prop of type_.properties) {
query.push(prop)
}
}
}
}
} else {
if (definition.properties.length > 0) {
query.push(...definition.properties)
}
}

if (Array.isArray(definition.inherits)) {
const inherits = definition.inherits.map(inherit => getDefinition(inherit.type))
for (const inherit of inherits) {
const properties = getProperties(inherit)
if (properties.path.length > 0) {
path.push(...properties.path)
}

if (properties.query.length > 0) {
query.push(...properties.query)
}

if (properties.body === Body.yesBody) {
body = properties.body
}
}
}

return { path, query, body }
}
}
18 changes: 16 additions & 2 deletions output/openapi/elasticsearch-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions output/openapi/elasticsearch-serverless-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 36 additions & 12 deletions output/schema/schema-serverless.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 36 additions & 12 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 203259f

Please sign in to comment.