Skip to content

Commit 57ad925

Browse files
Merge branch 'main' into reindex-from-remote-serverless
2 parents b10c7dc + 5e7f6ad commit 57ad925

File tree

113 files changed

+3205
-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.

113 files changed

+3205
-804
lines changed

compiler-rs/clients_schema_to_openapi/src/schemas.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,56 @@ impl<'a> TypesAndComponents<'a> {
404404
// TODO: typed-keys: add an extension to identify it?
405405
}
406406
Some(TypeAliasVariants::InternalTag(tag)) => {
407-
// TODO: add tag.default_tag as an extension
407+
// outputs a map of discriminator values to schema references
408+
// e.g. { "type1": "#/components/schemas/Type1", "type2": "#/components/schemas/Type2" }
409+
let mut disc_mapping = IndexMap::new();
410+
let ValueOf::UnionOf(union) = &alias.typ else {
411+
bail!("InternalTag type alias {} does not wrap a union", alias.base.name);
412+
};
413+
// Extract union members and build mapping
414+
for item in &union.items {
415+
let ValueOf::InstanceOf(instance) = item else {
416+
bail!(
417+
"InternalTag union member in type alias {} is not an instance_of",
418+
alias.base.name
419+
);
420+
};
421+
422+
match self.model.get_type(&instance.typ) {
423+
Ok(TypeDefinition::Interface(variant_itf)) => {
424+
// Find the discriminator property in the variant
425+
let Some(disc_prop) = variant_itf.properties.iter().find(|p| p.name == tag.tag) else {
426+
bail!(
427+
"InternalTag union member in type alias {} does not have discriminator property {}",
428+
alias.base.name,
429+
tag.tag
430+
);
431+
};
432+
433+
// Extract the literal value
434+
let ValueOf::LiteralValue(literal) = &disc_prop.typ else {
435+
bail!(
436+
"InternalTag union member in type alias {} has non-literal discriminator property {}",
437+
alias.base.name,
438+
tag.tag
439+
);
440+
};
441+
let discriminator_value = literal.value.to_string();
442+
let schema_ref = format!("#/components/schemas/{}", instance.typ.schema_name());
443+
disc_mapping.insert(discriminator_value, schema_ref);
444+
}
445+
_ => bail!(
446+
"InternalTag union member in type alias {} is not an interface",
447+
alias.base.name
448+
),
449+
}
450+
}
451+
disc_mapping.sort_unstable_keys();
452+
408453
schema.schema_data.discriminator = Some(Discriminator {
409454
property_name: tag.tag.clone(),
410-
mapping: Default::default(),
455+
mapping: disc_mapping,
456+
// TODO: add tag.default_tag as an extension
411457
extensions: Default::default(),
412458
});
413459
}
15.3 KB
Binary file not shown.

compiler/src/model/metamodel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ export class Endpoint {
469469
index?: string[]
470470
cluster?: string[]
471471
}
472+
473+
codegenExclude?: boolean
472474
}
473475

474476
export class UrlTemplate {

compiler/src/model/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ export function hoistRequestAnnotations (
634634
request: model.Request, jsDocs: JSDoc[], mappings: Record<string, model.Endpoint>, response: model.TypeName | null
635635
): void {
636636
const knownRequestAnnotations = [
637-
'rest_spec_name', 'behavior', 'class_serializer', 'index_privileges', 'cluster_privileges', 'doc_id', 'availability', 'doc_tag', 'ext_doc_id'
637+
'rest_spec_name', 'behavior', 'class_serializer', 'index_privileges', 'cluster_privileges', 'doc_id', 'availability', 'doc_tag', 'ext_doc_id', 'codegen_exclude'
638638
]
639639
// in most of the cases the jsDocs comes in a single block,
640640
// but it can happen that the user defines multiple single line jsDoc.
@@ -720,6 +720,9 @@ export function hoistRequestAnnotations (
720720
} else if (tag === 'doc_tag') {
721721
assert(jsDocs, value.trim() !== '', `Request ${request.name.name}'s @doc_tag cannot be empty`)
722722
endpoint.docTag = value.trim()
723+
} else if (tag === 'codegen_exclude') {
724+
// Mark this endpoint to be excluded from client code generation
725+
endpoint.codegenExclude = true
723726
} else {
724727
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
725728
}

compiler/src/steps/add-description.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@ export default async function addDescription (model: model.Model, jsonSpec: Map<
3232
const spec = jsonSpec.get(endpoint.name)
3333
assert(spec, `Can't find the json spec for ${endpoint.name}`)
3434

35-
for (const property of requestDefinition.path) {
36-
const definition = spec.url.paths.find(path => {
37-
if (path.parts == null) return false
38-
return path.parts[property.name] != null
39-
})
40-
if (definition?.parts != null) {
41-
const { description } = definition.parts[property.name]
42-
if (typeof description === 'string') {
43-
property.description = property.description ?? description
44-
}
45-
}
46-
}
47-
48-
if (spec.params != null) {
49-
for (const property of requestDefinition.query) {
50-
const param = spec.params[property.name]
51-
if (param != null && typeof param.description === 'string') {
52-
property.description = property.description ?? param.description
53-
}
54-
}
55-
}
56-
5735
if (spec.documentation.description != null) {
5836
requestDefinition.description = requestDefinition.description ?? spec.documentation.description
5937
}

docs/modeling-guide.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,28 @@ export class Example {
562562
}
563563
```
564564
565+
### Stability property for `@availability`
566+
567+
The `stability` property can be added to an `@availability` annotation to indicate the maturity and expected backwards-compatibility of an API or property.
568+
569+
Syntax:
570+
```ts
571+
/** @availability stack since=<version> stability=<value> */
572+
```
573+
574+
Values and meaning:
575+
- `stable` => "Generally available"
576+
- `beta` => "Beta"
577+
- `experimental` => "Technical Preview"
578+
579+
Examples:
580+
```ts
581+
/**
582+
* @rest_spec_name indices.create
583+
* @availability stack since=1.0.0 stability=experimental
584+
*/
585+
```
586+
565587
#### description
566588
567589
You can (and should!) add a description for each type and property. For an in-depth explanation of how to write good descriptions, see [Documenting the API specification](doc-comments-guide.md).

docs/overlays/elasticsearch-shared-overlays.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ actions:
1515
description: >
1616
The autoscaling APIs enable you to create and manage autoscaling policies and retrieve information about autoscaling capacity.
1717
Autoscaling adjusts resources based on demand. A deployment can use autoscaling to scale resources as needed, ensuring sufficient capacity to meet workload requirements.
18+
externalDocs:
19+
url: https://www.elastic.co/docs/deploy-manage/autoscaling
20+
description: Learn more about autoscaling.
1821
# B
1922
- name: analytics
2023
x-displayName: Behavioral analytics
@@ -35,6 +38,9 @@ actions:
3538
description: >
3639
The cluster APIs enable you to retrieve information about your infrastructure on cluster, node, or shard level.
3740
You can manage cluster settings and voting configuration exceptions, collect node statistics and retrieve node information.
41+
externalDocs:
42+
url: https://www.elastic.co/docs/deploy-manage/distributed-architecture/discovery-cluster-formation/cluster-state-overview
43+
description: Learn more about the cluster state.
3844
- name: health_report
3945
x-displayName: Cluster - Health
4046
description: >
@@ -57,6 +63,9 @@ actions:
5763
description: >
5864
The cross-cluster replication (CCR) APIs let you run replication operations, such as creating and managing follower indices or auto-follow patterns.
5965
Use CCR to replicate indices across clusters to maintain search availability during outages, reduce indexing impact, and lower search latency by serving requests closer to users.
66+
externalDocs:
67+
description: Learn more about cross-cluster replication.
68+
url: https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication
6069
# D
6170
- name: data stream
6271
x-displayName: Data stream
@@ -80,6 +89,9 @@ actions:
8089
description: >
8190
The enrich APIs enable you to manage enrich policies.
8291
An enrich policy is a set of configuration options used to add the right enrich data to the right incoming documents.
92+
externalDocs:
93+
url: https://www.elastic.co/docs/manage-data/ingest/transform-enrich/data-enrichment
94+
description: Learn more about data enrichment.
8395
- name: eql
8496
x-displayName: EQL
8597
description: >
@@ -99,10 +111,16 @@ actions:
99111
x-displayName: Features
100112
description: >
101113
The feature APIs enable you to introspect and manage features provided by Elasticsearch and Elasticsearch plugins.
114+
externalDocs:
115+
url: https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore#feature-state
116+
description: Learn more about feature states.
102117
- name: fleet
103118
x-displayName: Fleet
104119
description: >
105120
The Fleet APIs support Fleet’s use of Elasticsearch as a data store for internal agent and action data.
121+
externalDocs:
122+
url: https://www.elastic.co/docs/reference/fleet
123+
description: Learn more about Fleet.
106124
# G
107125
- name: graph
108126
x-displayName: Graph explore
@@ -116,6 +134,9 @@ actions:
116134
x-displayName: Index
117135
description: >
118136
Index APIs enable you to manage individual indices, index settings, aliases, mappings, and index templates.
137+
externalDocs:
138+
url: https://www.elastic.co/docs/manage-data/data-store/index-basics
139+
description: Learn more about indices.
119140
- name: ilm
120141
x-displayName: Index lifecycle management
121142
description: >
@@ -139,6 +160,9 @@ actions:
139160
- name: ingest
140161
x-displayName: Ingest
141162
description: Ingest APIs enable you to manage tasks and resources related to ingest pipelines and processors.
163+
externalDocs:
164+
url: https://www.elastic.co/docs/manage-data/ingest
165+
description: Learn more about ingesting data.
142166
# L
143167
- name: license
144168
x-displayName: Licensing
@@ -158,6 +182,9 @@ actions:
158182
x-displayName: Machine learning
159183
description: >
160184
The machine learning APIs enable you to retrieve information related to the Elastic Stack machine learning features.
185+
externalDocs:
186+
url: https://www.elastic.co/docs/explore-analyze/machine-learning
187+
description: Learn more about machine learning.
161188
- name: ml anomaly
162189
x-displayName: Machine learning anomaly detection
163190
description: >
@@ -183,8 +210,14 @@ actions:
183210
x-displayName: Migration
184211
description: >
185212
The migration APIs power Kibana's Upgrade Assistant feature.
213+
externalDocs:
214+
url: https://www.elastic.co/docs/deploy-manage/upgrade/prepare-to-upgrade/upgrade-assistant
215+
description: Learn more about Kibana's Upgrade Assistant.
186216
- name: monitoring
187217
x-displayName: Monitoring
218+
externalDocs:
219+
url: https://www.elastic.co/docs/deploy-manage/monitor
220+
description: Learn more about monitoring.
188221
# N
189222
- name: shutdown
190223
x-displayName: Node lifecycle
@@ -213,6 +246,9 @@ actions:
213246
x-displayName: Rollup
214247
description: >
215248
The rollup APIs enable you to create, manage, and retrieve information about rollup jobs.
249+
externalDocs:
250+
url: https://www.elastic.co/docs/manage-data/lifecycle/rollup
251+
description: Learn more about rollup.
216252
# S
217253
- name: script
218254
x-displayName: Script
@@ -221,23 +257,36 @@ actions:
221257
Use the stored script APIs to manage stored scripts and search templates.
222258
externalDocs:
223259
url: https://www.elastic.co/docs/explore-analyze/scripting
260+
description: Learn more about scripting.
224261
- name: search
225262
x-displayName: Search
226263
description: >
227264
The search APIs enable you to search and aggregate data stored in Elasticsearch indices and data streams.
265+
externalDocs:
266+
url: https://www.elastic.co/docs/explore-analyze
267+
description: Learn more about searching.
228268
- name: search_application
229269
x-displayName: Search application
230270
description: >
231271
The search application APIs enable you to manage tasks and resources related to Search Applications.
272+
externalDocs:
273+
url: https://www.elastic.co/docs/solutions/search/search-applications
274+
description: Learn more about search applications.
232275
- name: searchable_snapshots
233276
x-displayName: Searchable snapshots
234277
description: >
235278
The searchable snapshots APIs enable you to perform searchable snapshots operations.
279+
externalDocs:
280+
url: https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore/searchable-snapshots
281+
description: Learn more about searchable snapshots.
236282
- name: security
237283
x-displayName: Security
238284
description: >
239285
The security APIs enable you to perform security activities, and add, update, retrieve, and remove application privileges, role mappings, and roles.
240286
You can also create and update API keys and create and invalidate bearer tokens.
287+
externalDocs:
288+
url: https://www.elastic.co/docs/deploy-manage/security
289+
description: Learn more about security.
241290
- name: snapshot
242291
x-displayName: Snapshot and restore
243292
description: >
@@ -265,11 +314,17 @@ actions:
265314
The synonyms management API provides a convenient way to define and manage synonyms in an internal system index.
266315
Related synonyms can be grouped in a "synonyms set".
267316
Create as many synonym sets as you need.
317+
externalDocs:
318+
url: https://www.elastic.co/docs/solutions/search/full-text/search-with-synonyms
319+
description: Learn more about synonyms.
268320
# T
269321
- name: tasks
270322
x-displayName: Task management
271323
description: >
272324
The task management APIs enable you to retrieve information about tasks or cancel tasks running in a cluster.
325+
externalDocs:
326+
url: https://www.elastic.co/docs/troubleshoot/elasticsearch/task-queue-backlog
327+
description: Check out the troubleshooting the Task Management API.
273328
- name: text_structure
274329
x-displayName: Text structure
275330
description: >
@@ -278,6 +333,9 @@ actions:
278333
x-displayName: Transform
279334
description: >
280335
The transform APIs enable you to create and manage transforms.
336+
externalDocs:
337+
url: https://www.elastic.co/docs/explore-analyze/transforms
338+
description: Learn more about transforms.
281339
# U
282340
- name: xpack
283341
x-displayName: Usage
@@ -1166,4 +1224,4 @@ actions:
11661224
- target: "$.components['schemas']['_types.Duration']"
11671225
description: Re-add a simple string type for Duration
11681226
update:
1169-
type: string
1227+
type: string

0 commit comments

Comments
 (0)