kibana/dev_docs
Jean-Louis Leysens 5e90e557cf
[OAS] Support examples (and more) (#212495)
## Summary

Close https://github.com/elastic/kibana/issues/188926

Adds the ability to merge in an arbitrary OAS operation object (search
[spec](https://swagger.io/specification/) for "operation object") in
code generated OAS.

This enables us to write examples next to the code:

<img width="306" alt="Screenshot 2025-02-26 at 11 24 00"
src="https://github.com/user-attachments/assets/5df92ae9-c8c5-4797-8b7c-764e937e84e9"
/>

```ts
// Inside the router declaration
  router.post(
    {
      path: `${BASE_ALERTING_API_PATH}/rule/{id?}`,
      security: DEFAULT_ALERTING_ROUTE_SECURITY,
      options: {
        access: 'public',
        summary: `Create a rule`,
        tags: ['oas-tag:alerting'],
        // NEW 👇🏻: this file can contain operation-level OAS and will merge/override anything that we auto generate
        oasOperationObject: () => path.join(__dirname, 'create_rule.examples.yaml'),
        // ☝🏻 can also be a TS-checked OpenAPIV3.OperationObject
```

Tested with create rule example overlay
([gist](https://gist.github.com/jloleysens/dc643522a3f58dc2aed3dcef966b42df))
and bump

<img width="1236" alt="Screenshot 2025-02-26 at 11 45 57"
src="https://github.com/user-attachments/assets/c21b466a-ddab-49ce-b4ba-a04fd0e6c1b7"
/>

## Docs

Added developer guide docs to
https://docs.elastic.dev/kibana-dev-docs/genereating-oas-for-http-apis#2-route-definitions

<details>

<summary>images</summary>

<img width="799" alt="Screenshot 2025-03-13 at 13 02 31"
src="https://github.com/user-attachments/assets/e89b2c5a-1984-4672-a40b-b492581e690f"
/>

<img width="819" alt="Screenshot 2025-03-13 at 13 02 39"
src="https://github.com/user-attachments/assets/1375a25a-4d91-46b4-8ce5-42c763657d96"
/>

</details>




### TO DO
- [x] Document the feature in TS
- [x] Document feature in dev docs
- [x] Add tests

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2025-03-14 14:56:28 +01:00
..
assets Developer documentation for designing feature privileges (#166716) 2023-09-27 13:43:55 +02:00
contributing SKA: Update repository structure documentation (#208691) 2025-01-29 13:34:00 -06:00
getting_started SKA: Update broken references and URLs (#206836) 2025-01-28 03:32:48 +00:00
key_concepts [Hardening] Kibana Feature API Privileges Names (#208067) 2025-02-03 15:22:29 +01:00
lens [Lens] fit line charts by default (#196184) 2024-10-21 15:05:02 +02:00
operations [EuiProvider / Functional tests] Check for EuiProvider Dev Warning (#189018) 2024-08-26 15:08:32 -05:00
shared_ux [Screenshotting] Organize dev docs for screenshotting/chromium (#198100) 2024-10-30 11:55:12 -05:00
tutorials [OAS] Support examples (and more) (#212495) 2025-03-14 14:56:28 +01:00
api_welcome.mdx SKA: Update broken references and URLs (#206836) 2025-01-28 03:32:48 +00:00
kibana_server_core_components.mdx Clean up dev docs (#124271) 2022-02-03 10:09:10 -05:00
nav-kibana-dev.docnav.json Revert "[ResponseOps] Document creating task-manager serverless monitoring assets - adding to kibana dev docs navigation" (#211030) 2025-02-13 18:09:06 +01:00