Skip to content

Commit 3f07525

Browse files
authored
Merge branch 'main' into fix-cluster-stats-resp
2 parents 443a585 + 26ed911 commit 3f07525

File tree

285 files changed

+4685
-1321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+4685
-1321
lines changed

.backportrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"repoOwner": "elastic",
33
"repoName": "elasticsearch-specification",
4-
"targetBranchChoices": ["9.0", "8.19", "8.18", "8.17"],
4+
"targetBranchChoices": ["9.1", "9.0", "8.19", "8.18"],
55
"fork": false
66
}

.github/validate-pr/index.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ async function run() {
8686

8787
cd(tsValidationPath)
8888

89+
// Collect all APIs to validate
90+
const apisToValidate = new Set()
91+
8992
for (const file of specFiles) {
9093
if (file.startsWith('specification/_types')) continue
9194
if (file.startsWith('specification/_spec_utils')) continue
@@ -102,32 +105,35 @@ async function run() {
102105
.filter(endpoint => endpoint.name.split('.').filter(s => !privateNames.includes(s))[0] === getApi(file).split('.')[0])
103106
.map(endpoint => endpoint.name)
104107
for (const api of apis) {
105-
const report = await getReport({
106-
api,
107-
'generate-report': false,
108-
request: true,
109-
response: true,
110-
ci: false,
111-
verbose: false
112-
})
113-
const [namespace, _method] = api.split('.')
114-
// Asked to validate a specific API, so we only store that one
115-
reports.set(api, report.get(namespace)[0])
108+
apisToValidate.add(api)
116109
}
117110
} else {
118111
const api = getApi(file)
119-
const report = await getReport({
120-
api,
121-
'generate-report': false,
122-
request: true,
123-
response: true,
124-
ci: false,
125-
verbose: false
126-
})
127-
128-
const [namespace, _method] = api.split('.')
129-
// Asked to validate a specific API, so we only store that one
130-
reports.set(api, report.get(namespace)[0])
112+
apisToValidate.add(api)
113+
}
114+
}
115+
116+
// Call getReport once with all APIs
117+
if (apisToValidate.size > 0) {
118+
const allApis = Array.from(apisToValidate).join(',')
119+
const report = await getReport({
120+
api: allApis,
121+
'generate-report': false,
122+
request: true,
123+
response: true,
124+
ci: false,
125+
verbose: false
126+
})
127+
128+
// Extract individual API reports from the combined result
129+
for (const api of apisToValidate) {
130+
const namespace = getNamespace(api)
131+
if (report.has(namespace)) {
132+
const namespaceReport = report.get(namespace).find(r => r.api === getName(api))
133+
if (namespaceReport) {
134+
reports.set(api, namespaceReport)
135+
}
136+
}
131137
}
132138
}
133139

@@ -165,7 +171,6 @@ function getApi (file) {
165171
return file.split('/').slice(1, 3).filter(s => !privateNames.includes(s)).filter(Boolean).join('.')
166172
}
167173

168-
169174
function findBaselineReport(apiName, baselineValidation) {
170175
const [namespace, method] = apiName.split('.')
171176

.github/workflows/update-rest-api-json.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
branch: ['main', '9.0', '8.19', '8.18', '8.17']
16+
branch: ['main', '9.1', '9.0', '8.19', '8.18']
1717

1818
steps:
1919
- uses: actions/checkout@v4

.github/workflows/validate-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
with:
7373
issue-number: ${{ github.event.pull_request.number }}
7474
comment-author: 'github-actions[bot]'
75-
body-includes: 'Following you can find the validation results'
75+
body-includes: 'Following you can find the validation changes'
7676

7777
- name: Create or update comment
7878
if: steps.validation.outputs.has_results == 'true'

.gitignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ output/schema/schema
6565
# Test suite outputs
6666
compiler/test/**/output/
6767

68-
# Temporary openAPI files
69-
output/openapi/elasticsearch-serverless-openapi.tmp*.json
70-
output/openapi/elasticsearch-serverless-openapi.examples.json
71-
output/openapi/elasticsearch-openapi.tmp*.json
72-
output/openapi/elasticsearch-openapi.examples.json
73-
output/openapi/elasticsearch-serverless-openapi-docs.json
74-
output/openapi/elasticsearch-openapi-docs.json
68+
# Temporary openAPI documentation files
69+
output/openapi/elasticsearch-serverless-openapi-docs*.json
70+
output/openapi/elasticsearch-openapi-docs*.json
71+
output/openapi/elasticsearch*.redirects.csv

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ dump-routes: ## Create a new schema with all generics expanded
6969
@npm run dump-routes --prefix compiler
7070

7171
overlay-docs: ## Apply overlays to OpenAPI documents
72-
@npx bump overlay "output/openapi/elasticsearch-serverless-openapi.json" "docs/overlays/elasticsearch-serverless-openapi-overlays.yaml" > "output/openapi/elasticsearch-serverless-openapi.tmp1.json"
73-
@npx bump overlay "output/openapi/elasticsearch-serverless-openapi.tmp1.json" "docs/overlays/elasticsearch-shared-overlays.yaml" > "output/openapi/elasticsearch-serverless-openapi.tmp2.json"
74-
@npx @redocly/cli bundle output/openapi/elasticsearch-serverless-openapi.tmp2.json --ext json -o output/openapi/elasticsearch-serverless-openapi.examples.json
75-
@npx bump overlay "output/openapi/elasticsearch-openapi.json" "docs/overlays/elasticsearch-openapi-overlays.yaml" > "output/openapi/elasticsearch-openapi.tmp1.json"
76-
@npx bump overlay "output/openapi/elasticsearch-openapi.tmp1.json" "docs/overlays/elasticsearch-shared-overlays.yaml" > "output/openapi/elasticsearch-openapi.tmp2.json"
77-
@npx @redocly/cli bundle output/openapi/elasticsearch-openapi.tmp2.json --ext json -o output/openapi/elasticsearch-openapi.examples.json
78-
rm output/openapi/elasticsearch-serverless-openapi.tmp*.json
79-
rm output/openapi/elasticsearch-openapi.tmp*.json
72+
@npx bump overlay "output/openapi/elasticsearch-serverless-openapi-docs.json" "docs/overlays/elasticsearch-serverless-openapi-overlays.yaml" > "output/openapi/elasticsearch-serverless-openapi-docs.tmp1.json"
73+
@npx bump overlay "output/openapi/elasticsearch-serverless-openapi-docs.tmp1.json" "docs/overlays/elasticsearch-shared-overlays.yaml" > "output/openapi/elasticsearch-serverless-openapi-docs.tmp2.json"
74+
@npx @redocly/cli bundle output/openapi/elasticsearch-serverless-openapi-docs.tmp2.json --ext json -o output/openapi/elasticsearch-serverless-openapi-docs-final.json
75+
@npx bump overlay "output/openapi/elasticsearch-openapi-docs.json" "docs/overlays/elasticsearch-openapi-overlays.yaml" > "output/openapi/elasticsearch-openapi-docs.tmp1.json"
76+
@npx bump overlay "output/openapi/elasticsearch-openapi-docs.tmp1.json" "docs/overlays/elasticsearch-shared-overlays.yaml" > "output/openapi/elasticsearch-openapi-docs.tmp2.json"
77+
@npx @redocly/cli bundle output/openapi/elasticsearch-openapi-docs.tmp2.json --ext json -o output/openapi/elasticsearch-openapi-docs-final.json
78+
rm output/openapi/elasticsearch-serverless-openapi-docs.tmp*.json
79+
rm output/openapi/elasticsearch-openapi-docs.tmp*.json
8080

8181
generate-language-examples:
8282
@node docs/examples/generate-language-examples.js
@@ -89,11 +89,11 @@ generate-language-examples-with-java:
8989
lint-docs: ## Lint the OpenAPI documents after overlays
9090
@npx @redocly/cli lint "output/openapi/elasticsearch-*.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
9191

92-
lint-docs-stateful: ## Lint only the elasticsearch-openapi.examples.json file
93-
@npx @redocly/cli lint "output/openapi/elasticsearch-openapi.examples.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
92+
lint-docs-stateful: ## Lint only the elasticsearch-openapi-docs-final.json file
93+
@npx @redocly/cli lint "output/openapi/elasticsearch-openapi-docs-final.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
9494

9595
lint-docs-serverless: ## Lint only the serverless OpenAPI document after overlays
96-
@npx @redocly/cli lint "output/openapi/elasticsearch-serverless-openapi.examples.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
96+
@npx @redocly/cli lint "output/openapi/elasticsearch-serverless-openapi-docs-final.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
9797

9898
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs ## Pre contribution target
9999

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ $ make overlay-docs
7474
# The generated output can be found in ./output/openapi/
7575
```
7676

77+
## Specification Viewer
78+
79+
An interactive viewer for the Elasticsearch specification is available
80+
[here](https://elastic.github.io/specification-viewer/).
81+
7782
## Contributing
7883

7984
See [CONTRIBUTING.md](./CONTRIBUTING.md)
@@ -234,6 +239,9 @@ make validate api=xpack.info type=request branch=main
234239

235240
# this will validate the xpack.info request and response types against the 8.15 branch
236241
make validate api=xpack.info branch=8.15
242+
243+
# this will validate the xpack.info and search request and response types against the 8.15 branch
244+
make validate api=xpack.info,search branch=8.15
237245
```
238246

239247
The last command above will install all the dependencies and run, download

compiler-rs/clients_schema/src/transform/expand_generics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ pub fn expand(model: IndexedModel, config: ExpandConfig) -> anyhow::Result<Index
211211

212212
expand_behaviors(&mut resp.behaviors, &mappings, model, ctx)?;
213213
expand_body(&mut resp.body, &mappings, model, ctx)?;
214-
215-
// TODO: exceptions
214+
215+
for exception in &mut resp.exceptions {
216+
expand_body(&mut exception.body, &mappings, model, ctx)?;
217+
}
216218

217219
Ok(resp.into())
218220
}

compiler/run-validations.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ async function run () {
7878
process.exit(1)
7979
}
8080

81-
if (!apis.includes(options.api)) {
82-
spinner.fail(`The api '${options.api}' does not exists, did you mean '${closest(options.api, apis)}'?`)
81+
const apiList = options.api.split(',').map(api => api.trim())
82+
const invalidApis = apiList.filter(api => !apis.includes(api))
83+
if (invalidApis.length > 0) {
84+
const suggestions = invalidApis.map(api => `'${api}' (did you mean '${closest(api, apis)}'?)`).join(', ')
85+
spinner.fail(`The following APIs do not exist: ${suggestions}`)
8386
process.exit(1)
8487
}
8588
// if the empty string it's because the make target wasn't configured with a type argument

compiler/src/steps/validate-model.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,23 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
497497
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
498498
throw new Error(`Unknown kind: ${typeDef.body.kind}`)
499499
}
500+
501+
if (typeDef.exceptions != null) {
502+
for (const ex of typeDef.exceptions) {
503+
switch (ex.body.kind) {
504+
case 'properties':
505+
validateProperties(ex.body.properties, openGenerics, new Set<string>())
506+
break
507+
case 'value':
508+
validateValueOf(ex.body.value, openGenerics)
509+
break
510+
case 'no_body':
511+
// Nothing to validate
512+
break
513+
}
514+
}
515+
}
516+
500517
context.pop()
501518
}
502519

0 commit comments

Comments
 (0)