Closes#187638
## Summary
In this [PR](https://github.com/elastic/kibana/pull/186190), we
introduced @kbn/zod package and an OAS convertor to automatically
generate Open API Specifications for the routes that use zod for their
validation. In this PR, we add an eslint rule to enforce importing from
@kbn/zod instead of zod directly.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
**Resolves:** https://github.com/elastic/kibana/issues/183375
## Summary
This PR implements functionality assigning a provided tag to OpenAPI `Operation object`s in the result bundle. Specified tag is also added as the only root level OpenAPI tag. This approach allows to produce domain bundles having a single tag assigned. At the next step domain bundles are merged together into single Kibana bundle where tags will allow to properly display grouping at Bump.sh (API reference documentation platform).
## Details
Bump.sh (our new API reference documentation platform) uses OpenAPI tags for grouping API endpoints. It supports only one tag per endpoint.
This PR facilitates preparation of Kibana OpenAPI bundle to be uploaded to Bump.sh by implementing functionality assigning a provided tag to OpenAPI `Operation object`s in the result domain bundles. It's implemented by providing an optional configuration option `assignTag` whose format is OpenAPI Tag Object. When `assignTag` isn't specified the bundler merges existing tags.
## Example
Consider the following bundling configuration
```js
const { bundle } = require('@kbn/openapi-bundler');
bundle({
// ...
options: {
assignTag: {
name: 'Some Domain API tag name',
description: 'Some Domain API description',
externalDocs: {
url: 'https://some-external-documentation-url',
description: 'External documentation description',
}
},
});
```
and source OpenAPI specs
**spec1.schema.yaml**
```yaml
openapi: 3.0.3
info:
title: Spec1
version: '2023-10-31'
paths:
/api/some_api:
get:
tags: ['Some local tag']
responses:
200:
content:
'application/json':
schema:
type: string
```
**spec2.schema.yaml**
```yaml
openapi: 3.0.3
info:
title: Spec2
version: '2023-10-31'
paths:
/api/some_api:
post:
tags: ['Some global tag']
responses:
200:
content:
'application/json':
schema:
type: string
tags:
- name: Some global tag
```
**spec2.schema.yaml**
```yaml
openapi: 3.0.3
info:
title: Spec3
version: '2023-10-31'
paths:
/api/another_api:
get:
responses:
200:
content:
'application/json':
schema:
type: string
```
After bundling above OpenAPI specs with the provided bundling script we'll get the following
**domain-bundle.schema.yaml**
```yaml
openapi: 3.0.3
info:
title: Bundled document
version: '2023-10-31'
paths:
/api/some_api:
get:
tags: ['Some Domain API tag name']
responses:
200:
content:
'application/json':
schema:
type: string
post:
tags: ['Some Domain API tag name']
responses:
200:
content:
'application/json':
schema:
type: string
/api/another_api:
get:
tags: ['Some Domain API tag name']
responses:
200:
content:
'application/json':
schema:
type: string
tags:
- name: Some Domain API tag name
description: Some Domain API description
externalDocs:
url: 'https://some-external-documentation-url'
description: External documentation description
```
**Addresses**: https://github.com/elastic/kibana/issues/184428
## Summary
This PR adds scripts for automatic bundling of Exceptions API OpenAPI specs as a part of PR pipeline. Corresponding resulting bundles are automatically committed in the Lists common package `kbn-securitysolution-exceptions-common` in the `docs/openapi/ess/` and `docs/openapi/serverless` folders (similar to https://github.com/elastic/kibana/pull/186384).