Skip to content

add example requests for endpoints that do not use bodies #4489

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 7 commits into from
Jun 10, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 10 additions & 23 deletions compiler-rs/clients_schema_to_openapi/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,16 @@ pub fn add_endpoint(
// }
};

let openapi_example = Example {
value: example,
description: schema_example.description.clone(),
summary: schema_example.summary.clone(),
external_value: None,
extensions: Default::default(),
};
openapi_examples.insert(name.clone(), ReferenceOr::Item(openapi_example));
if example.is_some() {
let openapi_example = Example {
value: example,
description: schema_example.description.clone(),
summary: schema_example.summary.clone(),
external_value: None,
extensions: Default::default(),
};
openapi_examples.insert(name.clone(), ReferenceOr::Item(openapi_example));
}
}
openapi_examples
}
Expand Down Expand Up @@ -340,21 +342,6 @@ pub fn add_endpoint(
}
}
}
if code_samples.is_empty() {
// if there are no example requests we look for example responses
// this can only happen for examples that do not have a request body
if let Some(examples) = response_def.examples.clone() {
if let Some((_, example)) = examples.first() {
let request_line = example.method_request.clone().unwrap_or(String::from(""));
if !request_line.is_empty() {
code_samples.push(serde_json::json!({
"lang": "Console",
"source": request_line + "\n",
}));
}
}
}
}
if !code_samples.is_empty() {
extensions.insert("x-codeSamples".to_string(), serde_json::json!(code_samples));
}
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
11 changes: 0 additions & 11 deletions docs/overlays/elasticsearch-shared-overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,17 +1077,6 @@ actions:
# update:
# aggregations:
# x-model: true
# Examples
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Lisa! I forgot to look for this. :)

## xCodeSamples
- target: "$.paths['/{index}/_doc/{id}']['head']"
description: "Add xCodeSamples for check document operation"
update:
x-codeSamples:
- $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml"
- $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml"
- $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml"
- $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml"
- $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml"
# Remove long lists of enum values
- target: "$.components['schemas']['cat._types.CatAnomalyDetectorColumn'].enum"
description: Remove enum array
Expand Down
Loading
Loading