Skip to content

Commit 9b39b8a

Browse files
authored
Merge branch 'main' into fixing-index-create-partially
2 parents b1d3671 + 10487a1 commit 9b39b8a

File tree

249 files changed

+2176
-804
lines changed

Some content is hidden

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

249 files changed

+2176
-804
lines changed

.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

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ make validate api=xpack.info type=request branch=main
234234

235235
# this will validate the xpack.info request and response types against the 8.15 branch
236236
make validate api=xpack.info branch=8.15
237+
238+
# this will validate the xpack.info and search request and response types against the 8.15 branch
239+
make validate api=xpack.info,search branch=8.15
237240
```
238241

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

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

docs/add-new-api.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
It might happen that a new API in Elasticsearch is not yet defined
44
in this repository, or we do have an endpoint definition in [`/specification/_json_spec`](../specification/_json_spec)
55
but we don't have a type definition for it.
6-
In this document you will see how to add a new endpopint and how to add a new endpoint definition.
6+
In this document you will see how to add a new endpoint and how to add a new endpoint definition.
77

88
## How to add a new endpoint
99

10-
Add a new endpoint is straightforward, you only need to copy-paste the json rest-api-spec defintion
10+
Add a new endpoint is straightforward, you only need to copy-paste the json rest-api-spec definition
1111
from the Elasticsearch repository inside [`/specification/_json_spec`](../specification/_json_spec)
1212
and you are good to go.
1313

@@ -17,10 +17,10 @@ or [here](https://github.com/elastic/elasticsearch/tree/7.x/x-pack/plugin/src/te
1717
## How to add the definition of an endpoint
1818

1919
Once you have added a new endpoint definition, the next step is to add its type definition.
20-
First of all, you should find the most approariate place inside [`/specification`](../specification)
20+
First of all, you should find the most appropriate place inside [`/specification`](../specification)
2121
where to put the new definition. The content of [`/specification`](../specification)
22-
tryied to mimic the Elasticsearch online documentation, so you can use it as inspiration.
23-
For example, the index document defintion can be found in [`/specification/_global/index`](../specification/_global/index).
22+
tried to mimic the Elasticsearch online documentation, so you can use it as inspiration.
23+
For example, the index document definition can be found in [`/specification/_global/index`](../specification/_global/index).
2424

2525
Once you have found the best place for the new definition, you should create a new file for it.
2626
The filename should be the same of the type definition you are writing, for example:
@@ -40,16 +40,16 @@ you can define it in the same file where it's used, unless is a commonly used ty
4040

4141
### Add the endpoint request definition
4242

43-
Request definitions are slighly different from other definitions.
43+
Request definitions are slightly different from other definitions.
4444
It is required that the request definition is named `Request`.
45-
A request definition is an interface and should contains three top level keys:
45+
A request definition is an interface and should contain these top level keys:
4646

4747
- `urls`: the URL paths templates and allowed HTTP methods
4848
- `path_parts`: the path parameters (eg: `indices`, `id`...)
4949
- `query_parameters`: the query parameters (eg: `timeout`, `pipeline`...)
5050
- `body`: the body parameters (eg: `query` or user defined entities)
5151

52-
Furthermore, every request definition **must** contain three JS Doc tags:
52+
Furthermore, every request definition **must** contain these JS Doc tags:
5353

5454
- `@rest_spec_name`: the API name (eg: `search`, `indices.create`...).
5555
- `@availability` Which flavor of Elasticsearch is this API available for? (eg `stack` or `serverless`)
@@ -130,7 +130,7 @@ class Response {
130130
```
131131

132132
As you can see, for responses there are no custom top level keys, as the
133-
response definition represents the body of a succesful response.
133+
response definition represents the body of a successful response.
134134

135135
#### Generics
136136

@@ -172,7 +172,7 @@ class Response {
172172
Add an `examples` folder and `request` and `xxx_response` subfolders (where `xxx` is the relevant response code). The file names within these folders should be unique (for example,`DownsampleRequestExample1.yaml` not `RequestExample1.yaml`).
173173

174174
These examples are for use in the API documentation and must adhere to the [OpenAPI 3.0 Example object specification](https://spec.openapis.org/oas/v3.0.3#example-object). They must have a `value` field that contains the request or response body.
175-
If there are multiple examples for the endpoint, they must each have a brief `summary` field, which is used as the label for the example. You can also optionaly provide an explanation in a `description` field.
175+
If there are multiple examples for the endpoint, they must each have a brief `summary` field, which is used as the label for the example. You can also optionally provide an explanation in a `description` field.
176176
In order to generate curl and console examples automatically, the request examples must also contain a `method_request`.
177177

178178
For example:
@@ -197,5 +197,5 @@ value: |-
197197
```
198198
199199
NOTE: A good example covers a very common use case or demonstrates a more complex but critical use case.
200-
It involves realistic data sets ( rather than generic "hello world" values).
200+
It involves realistic data sets (rather than generic "hello world" values).
201201
If it requires detailed setup or explanations, however, it is more appropriate for coverage in longer-form narrative documentation.

docs/modeling-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ property: UserDefinedValue
148148

149149
### Numbers
150150

151-
The numeric type in TypeScript is `number`, but given that this specification targets mutliple languages,
151+
The numeric type in TypeScript is `number`, but given that this specification targets multiple languages,
152152
it offers a bunch of aliases that represent the type that should be used if the language supports it:
153153

154154
```ts
@@ -504,7 +504,7 @@ Code generators should track the `es_quirk` they implement and fail if a new unh
504504
505505
### Additional information
506506
507-
If needed, you can specify additional information on each type with the approariate JSDoc tag.
507+
If needed, you can specify additional information on each type with the appropriate JSDoc tag.
508508
Following you can find a list of the supported tags:
509509
510510
#### `@availability`

docs/specification-structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ end with `Request` or `Response`.
3030
### Request and Response definitions
3131

3232
Request and Response definitions should be placed by strictly following
33+
the rest-api-spec structure.
3334
the `rest-api-spec` structure.
3435
For example, the request and response definition for `indices.put_mapping`
3536
should go in [`/specification/indices/put_mapping`](../specification/indices/put_mapping).

docs/validation-example.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The example assumes that you have already performed the necessary steps to run a
1616
if not, take a look at the [README](../README.md).
1717

1818
```sh
19-
make validate api=index type=request branch=main
19+
make validate api=index branch=main
2020
```
2121

2222
You will see an output like the following:
@@ -82,7 +82,7 @@ open it with your favourite editor and perform the fix
8282
Finally run the validation again:
8383

8484
```sh
85-
make validate api=index type=request branch=main
85+
make validate api=index branch=main
8686
```
8787

8888
If there are no more errors, open a pull request with the fix.

0 commit comments

Comments
 (0)