Skip to content

Add 8.18 documentation URLs to schema and OpenAPI #4638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions compiler-rs/clients_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub trait Documented {
pub trait ExternalDocument {
fn ext_doc_id(&self) -> Option<&str>;
fn ext_doc_url(&self) -> Option<&str>;
fn ext_previous_version_doc_url(&self) -> Option<&str>;
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down Expand Up @@ -322,6 +323,9 @@ pub struct Property {
#[serde(skip_serializing_if = "Option::is_none")]
pub ext_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ext_previous_version_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ext_doc_id: Option<String>,

Expand Down Expand Up @@ -371,6 +375,10 @@ impl ExternalDocument for Property {
self.ext_doc_url.as_deref()
}

fn ext_previous_version_doc_url(&self) -> Option<&str> {
self.ext_previous_version_doc_url.as_deref()
}

fn ext_doc_id(&self) -> Option<&str> {
self.ext_doc_id.as_deref()
}
Expand Down Expand Up @@ -528,6 +536,9 @@ pub struct BaseType {
#[serde(skip_serializing_if = "Option::is_none")]
pub ext_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ext_previous_version_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ext_doc_id: Option<String>,

Expand Down Expand Up @@ -568,6 +579,7 @@ impl BaseType {
spec_location: None,
ext_doc_id: None,
ext_doc_url: None,
ext_previous_version_doc_url: None,
}
}
}
Expand All @@ -591,6 +603,10 @@ impl ExternalDocument for BaseType {
self.ext_doc_url.as_deref()
}

fn ext_previous_version_doc_url(&self) -> Option<&str> {
self.ext_previous_version_doc_url.as_deref()
}

fn ext_doc_id(&self) -> Option<&str> {
self.ext_doc_id.as_deref()
}
Expand Down Expand Up @@ -619,6 +635,10 @@ impl<T: WithBaseType> ExternalDocument for T {
self.base().doc_url()
}

fn ext_previous_version_doc_url(&self) -> Option<&str> {
self.base().ext_previous_version_doc_url()
}

fn ext_doc_id(&self) -> Option<&str> {
self.base().doc_id()
}
Expand Down Expand Up @@ -895,6 +915,9 @@ pub struct Endpoint {
#[serde(skip_serializing_if = "Option::is_none")]
pub ext_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub ext_previous_version_doc_url: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub deprecation: Option<Deprecation>,

Expand Down Expand Up @@ -945,6 +968,10 @@ impl ExternalDocument for Endpoint {
self.ext_doc_url.as_deref()
}

fn ext_previous_version_doc_url(&self) -> Option<&str> {
self.ext_previous_version_doc_url.as_deref()
}

fn ext_doc_id(&self) -> Option<&str> {
self.ext_doc_id.as_deref()
}
Expand Down
6 changes: 5 additions & 1 deletion compiler-rs/clients_schema_to_openapi/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ impl<'a> TypesAndComponents<'a> {
.as_ref()
.and_then(|i| i.version.as_deref())
.unwrap_or("current");
let mut extensions: IndexMap<String,serde_json::Value> = Default::default();
if let Some(previous_version_doc_url) = obj.ext_previous_version_doc_url() {
extensions.insert("x-previousVersionUrl".to_string(), serde_json::json!(previous_version_doc_url));
}
ExternalDocumentation {
description: None,
url: url.trim().replace("{branch}", branch),
extensions: Default::default(),
extensions,
}
})
}
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions compiler-rs/openapi_to_clients_schema/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ fn generate_interface_def(
doc_url: None,
ext_doc_id: None,
ext_doc_url: None,
ext_previous_version_doc_url: None,
codegen_name: None, // FIXME: extension in workplace search
description: None,
aliases: Vec::default(),
Expand Down
1 change: 1 addition & 0 deletions compiler/src/model/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ export class Endpoint {
docId?: string
extDocId?: string
extDocUrl?: string
extPreviousVersionDocUrl?: string
deprecation?: Deprecation
availability: Availabilities
docTag?: string
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/model/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ export function hoistRequestAnnotations (
const docUrl = docIds.find(entry => entry[0] === value.trim())
assert(jsDocs, docUrl != null, `The @doc_id '${value.trim()}' is not present in _doc_ids/table.csv`)
endpoint.docUrl = docUrl[1].replace(/\r/g, '')
if (docUrl[2].replace(/\r/g, '') !== '') {
endpoint.extPreviousVersionDocUrl = docUrl[2].replace(/\r/g, '')
}
} else if (tag === 'ext_doc_id') {
assert(jsDocs, value.trim() !== '', `Request ${request.name.name}'s @ext_doc_id cannot be empty`)
endpoint.extDocId = value.trim()
Expand Down
507 changes: 338 additions & 169 deletions output/openapi/elasticsearch-openapi.json

Large diffs are not rendered by default.

219 changes: 146 additions & 73 deletions output/openapi/elasticsearch-serverless-openapi.json

Large diffs are not rendered by default.

Loading
Loading