Skip to content

Commit 680b548

Browse files
committed
Merge branch 'main' into ip-location-apis
2 parents f3a5f78 + 0190dd4 commit 680b548

File tree

193 files changed

+6760
-2333
lines changed

Some content is hidden

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

193 files changed

+6760
-2333
lines changed

.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', '8.x', '8.16', '8.17', 7.17']
16+
branch: ['main', '8.x', '8.16', '8.17', '7.17']
1717

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

compiler/src/model/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ export function hoistRequestAnnotations (
667667
} else if (tag === 'cluster_privileges') {
668668
const privileges = [
669669
'all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr',
670-
'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_ingest_pipelines', 'manage_logstash_pipelines',
670+
'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines',
671671
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml',
672672
'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile',
673673
'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',

compiler/src/steps/validate-model.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
149149

150150
// Register builtin types
151151
for (const name of [
152-
'string', 'boolean', 'number', 'null'
152+
'string', 'boolean', 'number', 'null', 'void', 'binary'
153153
]) {
154154
const typeName = {
155155
namespace: '_builtins',
@@ -397,11 +397,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
397397
context.pop()
398398

399399
context.push('body')
400-
if (typeDef.inherits != null && typeDef.body.kind !== 'properties') {
401-
if (fqn(typeDef.inherits.type) !== '_types:RequestBase') {
402-
modelError('A request with inherited properties must have a PropertyBody')
403-
}
404-
}
405400
switch (typeDef.body.kind) {
406401
case 'properties':
407402
validateProperties(typeDef.body.properties, openGenerics, inheritedProps)
@@ -546,33 +541,29 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
546541
}
547542

548543
function validateTypeAlias (typeDef: model.TypeAlias): void {
549-
const openGenerics = new Set(typeDef.generics?.map(t => t.name))
544+
const openGenerics = openGenericSet(typeDef)
550545

551546
if (typeDef.variants != null) {
552-
if (typeDef.generics != null && typeDef.generics.length !== 0) {
553-
modelError('A tagged union should not have generic parameters')
554-
}
555-
556547
if (typeDef.type.kind !== 'union_of') {
557548
modelError('The "variants" tag only applies to unions')
558549
} else {
559-
validateTaggedUnion(typeDef.name, typeDef.type, typeDef.variants)
550+
validateTaggedUnion(typeDef.name, typeDef.type, typeDef.variants, openGenerics)
560551
}
561552
} else {
562553
validateValueOf(typeDef.type, openGenerics)
563554
}
564555
}
565556

566-
function validateTaggedUnion (parentName: TypeName, valueOf: model.UnionOf, variants: model.InternalTag | model.ExternalTag | model.Untagged): void {
557+
function validateTaggedUnion (parentName: TypeName, valueOf: model.UnionOf, variants: model.InternalTag | model.ExternalTag | model.Untagged, openGenerics: Set<string>): void {
567558
if (variants.kind === 'external_tag') {
568559
// All items must have a 'variant' attribute
569-
const items = flattenUnionMembers(valueOf)
560+
const items = flattenUnionMembers(valueOf, openGenerics)
570561

571562
for (const item of items) {
572563
if (item.kind !== 'instance_of') {
573564
modelError('Items of externally tagged unions must be types with a "variant_tag" annotation')
574565
} else {
575-
validateTypeRef(item.type, undefined, new Set<string>())
566+
validateTypeRef(item.type, item.generics, openGenerics)
576567
const type = getTypeDef(item.type)
577568
if (type == null) {
578569
modelError(`Type ${fqn(item.type)} not found`)
@@ -587,13 +578,13 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
587578
}
588579
} else if (variants.kind === 'internal_tag') {
589580
const tagName = variants.tag
590-
const items = flattenUnionMembers(valueOf)
581+
const items = flattenUnionMembers(valueOf, openGenerics)
591582

592583
for (const item of items) {
593584
if (item.kind !== 'instance_of') {
594585
modelError('Items of internally tagged unions must be type references')
595586
} else {
596-
validateTypeRef(item.type, undefined, new Set<string>())
587+
validateTypeRef(item.type, item.generics, openGenerics)
597588
const type = getTypeDef(item.type)
598589
if (type == null) {
599590
modelError(`Type ${fqn(item.type)} not found`)
@@ -606,7 +597,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
606597
}
607598
}
608599

609-
validateValueOf(valueOf, new Set())
600+
validateValueOf(valueOf, openGenerics)
610601
} else if (variants.kind === 'untagged') {
611602
if (fqn(parentName) !== '_types.query_dsl:DecayFunction' &&
612603
fqn(parentName) !== '_types.query_dsl:DistanceFeatureQuery' &&
@@ -619,15 +610,15 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
619610
modelError(`Type ${fqn(variants.untypedVariant)} not found`)
620611
}
621612

622-
const items = flattenUnionMembers(valueOf)
613+
const items = flattenUnionMembers(valueOf, openGenerics)
623614
const baseTypes = new Set<string>()
624615
let foundUntyped = false
625616

626617
for (const item of items) {
627618
if (item.kind !== 'instance_of') {
628619
modelError('Items of type untagged unions must be type references')
629620
} else {
630-
validateTypeRef(item.type, undefined, new Set<string>())
621+
validateTypeRef(item.type, item.generics, openGenerics)
631622
const type = getTypeDef(item.type)
632623
if (type == null) {
633624
modelError(`Type ${fqn(item.type)} not found`)
@@ -679,7 +670,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
679670
// -----------------------------------------------------------------------------------------------
680671
// Constituents of type definitions
681672

682-
function openGenericSet (typeDef: model.Request | model.Response | model.Interface): Set<string> {
673+
function openGenericSet (typeDef: model.Request | model.Response | model.Interface | model.TypeAlias): Set<string> {
683674
return new Set((typeDef.generics ?? []).map(name => fqn(name)))
684675
}
685676

@@ -884,7 +875,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
884875
} else {
885876
// tagged union: the discriminant tells us what to look for, check each member in isolation
886877
assert(typeDef.type.kind === 'union_of', 'Variants are only allowed on union_of type aliases')
887-
for (const item of flattenUnionMembers(typeDef.type)) {
878+
for (const item of flattenUnionMembers(typeDef.type, new Set())) {
888879
validateValueOfJsonEvents(item)
889880
}
890881

@@ -899,13 +890,13 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
899890
}
900891

901892
/** Build the flattened item list of potentially nested unions (this is used for large unions) */
902-
function flattenUnionMembers (union: model.UnionOf): model.ValueOf[] {
893+
function flattenUnionMembers (union: model.UnionOf, openGenerics: Set<string>): model.ValueOf[] {
903894
const allItems = new Array<model.ValueOf>()
904895

905896
function collectItems (items: model.ValueOf[]): void {
906897
for (const item of items) {
907898
if (item.kind !== 'instance_of') {
908-
validateValueOf(item, new Set<string>())
899+
validateValueOf(item, openGenerics)
909900
allItems.push(item)
910901
} else {
911902
const itemType = getTypeDef(item.type)
@@ -915,7 +906,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
915906
// Recurse in nested union
916907
collectItems(itemType.type.items)
917908
} else {
918-
validateValueOf(item, new Set<string>())
909+
validateValueOf(item, openGenerics)
919910
allItems.push(item)
920911
}
921912
}

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

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

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

docs/overlays/elasticsearch-openapi-overlays.yaml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ actions:
163163
- target: "$.paths['/_ilm/policy/{policy}']['put']"
164164
description: "Add examples for create a lifecycle operation"
165165
update:
166-
update:
167166
requestBody:
168167
content:
169168
application/json:
@@ -188,7 +187,6 @@ actions:
188187
- target: "$.paths['/_ilm/migrate_to_data_tiers']['post']"
189188
description: "Add examples for migrate to data tiers routing operation"
190189
update:
191-
update:
192190
requestBody:
193191
content:
194192
application/json:
@@ -205,7 +203,6 @@ actions:
205203
- target: "$.paths['/_ilm/move/{index}']['post']"
206204
description: "Add examples for move to lifecycle step operation"
207205
update:
208-
update:
209206
requestBody:
210207
content:
211208
application/json:
@@ -338,7 +335,6 @@ actions:
338335
- target: "$.paths['/_autoscaling/policy/{name}']['put']"
339336
description: "Add examples for create autoscaling policy operation"
340337
update:
341-
update:
342338
requestBody:
343339
content:
344340
application/json:
@@ -353,4 +349,46 @@ actions:
353349
application/json:
354350
examples:
355351
createAutoscalingPolicyResponseExample1:
356-
$ref: "../../specification/autoscaling/put_autoscaling_policy/autoscalingApisPutAutoscalingPolicyResponseExample1.yaml"
352+
$ref: "../../specification/autoscaling/put_autoscaling_policy/autoscalingApisPutAutoscalingPolicyResponseExample1.yaml"
353+
- target: "$.components['responses']['indices.recovery#200']"
354+
description: "Add example for get index recovery response"
355+
update:
356+
content:
357+
application/json:
358+
examples:
359+
getIndicesRecoveryResponseExample1:
360+
$ref: "../../specification/indices/recovery/indicesRecoveryResponseExample1.yaml"
361+
- target: "$.paths['/_resolve/cluster/{name}']['get']"
362+
description: "Add examples for resolve cluster operation"
363+
update:
364+
responses:
365+
200:
366+
content:
367+
application/json:
368+
examples:
369+
resolveClusterResponseExample1:
370+
$ref: "../../specification/indices/resolve_cluster/ResolveClusterResponseExample1.yaml"
371+
- target: "$.components['requestBodies']['indices.shrink']"
372+
description: "Add example for shrink index request"
373+
update:
374+
content:
375+
application/json:
376+
examples:
377+
indicesShrinkRequestExample1:
378+
$ref: "../../specification/indices/shrink/indicesShrinkRequestExample1.yaml"
379+
- target: "$.components['requestBodies']['indices.split']"
380+
description: "Add example for split index request"
381+
update:
382+
content:
383+
application/json:
384+
examples:
385+
indicesSplitRequestExample1:
386+
$ref: "../../specification/indices/split/indicesSplitRequestExample1.yaml"
387+
- target: "$.components['requestBodies']['indices.put_template']"
388+
description: "Add example for legacy create template request"
389+
update:
390+
content:
391+
application/json:
392+
examples:
393+
indicesLegacyPutTemplateRequestExample1:
394+
$ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml"

docs/overlays/elasticsearch-serverless-openapi-overlays.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ actions:
2323
- target: '$.components'
2424
description: Add securitySchemes
2525
update:
26-
securitySchemes:
27-
apiKeyAuth:
28-
description: |
29-
Elasticsearch APIs use key-based authentication.
30-
You must create an API key and use the encoded value in the request header.
31-
For example:
32-
33-
34-
```
35-
curl -X GET "${ES_URL}/_cat/indices?v=true" \
36-
-H "Authorization: ApiKey ${API_KEY}"
37-
```
38-
39-
To get API keys for the Elasticsearch endpoint (${ES_URL}) for a project, refer to [Connect to your Elasticsearch Serverless endpoint](https://www.elastic.co/guide/en/serverless/current/elasticsearch-connecting-to-es-serverless-endpoint.html).
40-
in: header
41-
name: Authorization
42-
type: apiKey
26+
securitySchemes:
27+
apiKeyAuth:
28+
description: |
29+
Elasticsearch APIs use key-based authentication.
30+
You must create an API key and use the encoded value in the request header.
31+
For example:
32+
33+
34+
```
35+
curl -X GET "${ES_URL}/_cat/indices?v=true" \
36+
-H "Authorization: ApiKey ${API_KEY}"
37+
```
38+
39+
To get API keys for the Elasticsearch endpoint (${ES_URL}) for a project, refer to [Connect to your Elasticsearch Serverless endpoint](https://www.elastic.co/guide/en/serverless/current/elasticsearch-connecting-to-es-serverless-endpoint.html).
40+
in: header
41+
name: Authorization
42+
type: apiKey
4343
- target: '$'
4444
description: Add document security
4545
update:

0 commit comments

Comments
 (0)