Skip to content

Add availability metadata to examples#6446

Merged
lcawl merged 2 commits into
mainfrom
example-availability
Jul 17, 2026
Merged

Add availability metadata to examples#6446
lcawl merged 2 commits into
mainfrom
example-availability

Conversation

@lcawl

@lcawl lcawl commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Solves #5197

Summary

Adds optional availability metadata to request and response example YAML files so the OpenAPI generator can include or exclude examples by Stack vs Serverless context. This addresses #5197 with a source-level solution instead of post-generation overlays (e.g. #6414).

Example YAML files can now declare:

availability: [stack]       # Stack only
availability: [serverless]  # Serverless only

When omitted, examples apply to all contexts (no migration required for existing examples).

The compiler normalizes this list into the existing Availabilities metamodel shape, and the availability filter removes non-matching examples before OpenAPI generation. That affects:

  • requestBody / response examples
  • x-codeSamples (which uses the first remaining request example after filtering)

Availability is used only for filtering; it is not emitted into OpenAPI output.

Changes

  • Metamodel: Added optional availability to Example / SchemaExample (TS + Rust).
  • Example loading (add-examples.ts): Parse, validate, and normalize availability: [stack|serverless] from YAML.
  • Filtering (availability.rs, filter-by-availability.ts): Filter request and response examples by flavor alongside endpoints and properties.
  • Seeded examples:
    • Rollover: Example1 → [stack], Example2 → [serverless]
    • Create index: Example1–3 → [stack]; new Example4–6 → [serverless] (empty body, mappings-only, aliases without routing)
  • Docs: Documented the field in add-new-api.md and modeling-guide.md.
  • WASM: Rebuilt compiler-wasm-lib to pick up Rust changes.

Examples

When I run make transform-to-openapi-for-docs and make overlay-docs, I see changes like this:

  • indicesRolloverRequestExample2 has been removed from the Stack-specific OpenAPI document
  • indicesRolloverRequestExample1 has been removed from the Serverless-specific OpenAPI document
  • indicesCreateRequestExample1 exists only in the Stack-specific OpenAPI document

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: Composer 2.5

@github-actions

Copy link
Copy Markdown
Contributor

Following you can find the validation changes against the target branch for the APIs.

No changes detected.

You can validate these APIs yourself by using the make validate target.

@ankikuma

Copy link
Copy Markdown

Thanks @lcawl. I think we will need a follow up to make the following fix.

We refer to the following GLOBALLY_REJECTED_PARAMETERS in many places in the serverless specs:
master_timout
routing
wait_for_active_shards

We will need to filter those out.

LGTM otherwise.

@lcawl
lcawl merged commit 4fcfdc5 into main Jul 17, 2026
18 checks passed
@lcawl
lcawl deleted the example-availability branch July 17, 2026 13:22
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown

The backport to 8.19 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.19 8.19
# Navigate to the new working tree
cd .worktrees/backport-8.19
# Create a new branch
git switch --create backport-6446-to-8.19
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4fcfdc57fa218487d0ab56048f83c99c3cb4fb59
# Push it to GitHub
git push --set-upstream origin backport-6446-to-8.19
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.19

Then, create a pull request where the base branch is 8.19 and the compare/head branch is backport-6446-to-8.19.

@github-actions

Copy link
Copy Markdown
Contributor

AI Backport Resolver resolved conflicts and created a backport PR: #6494

Files with AI-resolved conflicts:

  • compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm

l-trotta pushed a commit that referenced this pull request Jul 17, 2026
(cherry picked from commit 4fcfdc5)

Co-authored-by: Lisa Cawley <lcawley@elastic.co>
l-trotta added a commit that referenced this pull request Jul 17, 2026
* Add availability metadata to examples (#6446)

(cherry picked from commit 4fcfdc5)

* update wasm

* actually update wasm

---------

Co-authored-by: Lisa Cawley <lcawley@elastic.co>
Co-authored-by: Laura Trotta <laura.trotta@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants