Skip to content

[9.4] [Cases][Docs] - Add additional examples and cleanup to openApi (#263617)#265404

Merged
christineweng merged 4 commits intoelastic:9.4from
christineweng:backport/9.4/pr-263617
Apr 24, 2026
Merged

[9.4] [Cases][Docs] - Add additional examples and cleanup to openApi (#263617)#265404
christineweng merged 4 commits intoelastic:9.4from
christineweng:backport/9.4/pr-263617

Conversation

@christineweng
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.4:

Questions ?

Please refer to the Backport tool documentation

…ic#263617)

## Summary

This PR is a housekeeping pass on the public API documentation for
Kibana Cases. The docs had drifted from reality — some fields were
missing, some examples were wrong, some endpoints had no code samples,
and the docs validator was throwing 22 errors. This PR makes the docs
match what the API actually returns, and gets the validator to pass
cleanly.

Nothing about the API itself changes. Only documentation and its
generated bundles.

## The four kinds of fixes

### 1. Added missing "unauthorized" (401) examples

Every Cases endpoint was missing an example for its 401 response, which
tripped the validator. Rather than copy-pasting the same example 16
times, a shared `components/examples/response_401.yaml` was created and
referenced everywhere. One endpoint
(`paths/api@cases@alerts@{alertid}.yaml`) was also using a deprecated
`example:` format and got converted to the modern `examples:` map.

### 2. Filled in missing code samples and request examples

Four endpoints gained curl + Console code samples or request-body
examples — most notably:

- **File upload** (`paths/api@cases@{caseid}@files.yaml`) — now shows
multipart form usage
- **Push-to-connector**
(`paths/api@cases@{caseid}@connector@{connectorid}@_push.yaml`) —
clarified that no body is needed
- **Delete comments** (both bulk and single) — added curl + Console
samples

Five query-parameter component files also got `example:` values so the
rendered docs aren't blank:

- `page_index.yaml` → `1`
- `page_size.yaml` → `20`
- `sort_order.yaml` → `desc`
- `severity.yaml` → `low`
- `search.yaml` → `Case title 1`

### 3. Schema inaccuracies — docs didn't match reality

Three notable gaps between docs and actual API responses:

- **`incremental_id` on cases** — added to
`case_response_properties.yaml` and `case_response_get_case.yaml`, with
a note that it's populated asynchronously and won't appear in the
immediate `POST` response.
- **User-action `type` enum was stale** — had 11 values, should have had
16. Added `category`, `customFields`, `delete_case`, `extended_fields`,
`observables` to `user_actions_find_response_properties.yaml`.
- **`observableTypes` was completely missing** from the
case-configuration response schema — added to
`case_configure_response_properties.yaml`.

### 4. Example payloads didn't match real API output

Author tested example files against a live Kibana and patched
discrepancies:

- **`add_comment_response.yaml`** — was missing `pushed_at`,
`pushed_by`, `updated_at`, `updated_by`, and `profile_uid` on
`created_by`.
- **`push_case_response.yaml`** — was missing `assignees`,
`customFields`, `category`, and `profile_uid` on
`created_by`/`updated_by`.

## Why the diff looks huge (+41,888 / −84,370)

Don't be alarmed by the size. The vast majority of the churn is in three
regenerated files:

- `oas_docs/output/kibana.yaml` (+40,991 / −84,137)
- `x-pack/platform/plugins/shared/cases/docs/openapi/bundled-types.json`
-
`x-pack/platform/plugins/shared/cases/docs/openapi/bundled-types.schema.yaml`

These are machine-generated bundles. A manual post-bundle fixup was
applied to the schema YAML to convert Redocly's file-path discriminator
mappings (`foo.yaml`) into the `#/components/schemas/foo` format that
`kbn-openapi-bundler` requires, so that `make merge-api-docs-stateful`
continues to work.

## Key files to actually review

The hand-written changes (everything non-generated) are concentrated in:

- `components/examples/` — new shared 401 example + updated response
examples
- `components/parameters/` — added example values
- `components/schemas/` — the three schema fixes
- `paths/` — 16 path files got the 401 reference; a handful got new code
samples

## Bottom line

Docs-only cleanup. No runtime behavior changes, no tests to run, just
safer and more accurate public API documentation. Validator now passes
with **0 errors**.

- written with Claude

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 61a520d)

# Conflicts:
#	src/platform/packages/private/kbn-validate-oas/src/oas_error_baseline.json
#	x-pack/platform/plugins/shared/cases/common/bundled-types.gen.ts
@christineweng christineweng added the backport This PR is a backport of another PR label Apr 23, 2026
@christineweng christineweng enabled auto-merge (squash) April 23, 2026 21:33
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 2.3MB 2.3MB +184.0B

History

@christineweng christineweng merged commit 507401b into elastic:9.4 Apr 24, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants