Commit graph

10 commits

Author SHA1 Message Date
natasha-moore-elastic
cebcf01d35
[DOCS] Adds conceptual content to API docs (#202305)
## Summary

Resolves https://github.com/elastic/security-docs-internal/issues/49.

In order to retire asciidoc API docs, we first need to move over any
relevant content from those docs to the API reference site. This PR adds
the relevant conceptual information from:

-
https://www.elastic.co/guide/en/security/master/exceptions-api-overview.html
-
https://www.elastic.co/guide/en/security/master/lists-api-overview.html
- https://www.elastic.co/guide/en/security/master/rule-api-overview.html

### Previews:
Bump previews expire after 30min, so I'm providing screenshots below:

Detections preview:

![detections_preview](https://github.com/user-attachments/assets/c47b9d85-b5d0-4a32-8668-dc1ae2215681)

Exceptions preview:

![exceptions_preview](https://github.com/user-attachments/assets/b3fe9139-2162-4c56-bba9-751dffa11cb4)

Lists preview:

![lists_preview](https://github.com/user-attachments/assets/1c714f17-825d-45c7-8112-cc3d25c51047)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-12-12 16:53:29 +00:00
Devin W. Hurley
35aeac1043
[Security Solution] Fixes exception item comment validation on newline chars \n (#202063)
## Summary

Fixes: https://github.com/elastic/kibana/issues/201820

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-12-10 17:19:32 -05:00
Maxim Palenov
102297ca15
[HTTP/OAS] Include Security Solution domain OAS to production docs (#194132)
*Epic:** https://github.com/elastic/security-team/issues/9401 (internal)

## Summary

This PR includes Security Solution OpenAPI domain bundles into the production OpenAPI Kibana bundle. The result Kibana bundler is expected to be published to Bump.sh manually by @lcawl.
2024-10-04 22:34:25 +03:00
Maxim Palenov
101fcfe436
[Security Solution] Omit Solution from tags and titles in Security Solution's OpenAPI bundles (#193669)
**Relates to:** https://github.com/elastic/kibana/issues/184428

## Summary

This PR omit `Solution` from from tag names and titles in Security Solution's OpenAPI bundles based on Security Docs team recommendation.
2024-09-24 14:23:00 -05:00
Elena Shostak
28aa274f66
Updated js-yaml to v4 (#190678)
## Summary
Updated `js-yaml` to `4.1.0`.

This PR also introduces a type override for the `js-yaml` load function
to maintain compatibility across the codebase. Specifically, updated
type definition of the load function looks as follows:

```typescript
function load<T = any>(str: string, opts?: jsyaml.LoadOptions): T;
```

The original type definition of the load function in `js-yaml` changed
from `any` to `unknown`. This change would require extensive type
updates throughout the entire repository to accommodate the `unknown`
type. To avoid widespread type changes and potential issues in the
codebase, the type is overriden back to `any` for now.
This is a temporary measure, we plan to address the necessary type
changes in subsequent PRs, where teams will gradually update the
codebase to work with the `unknown` type.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

## Release note
Updated `js-yaml` to `4.1.0`.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
2024-09-19 12:25:03 +02:00
natasha-moore-elastic
5c5897966a
Improves Lists API docs content (#192504)
## Summary

Resolves https://github.com/elastic/security-docs-internal/issues/32 by
improving the Lists API docs content. Adds missing and improves existing
operation summaries and operation descriptions to adhere to our [OAS
standards](450494532/API+reference+docs).

Note: Couldn’t add description for the GET /api/lists/privileges
operation, since it's not documented in [ESS API
docs](https://www.elastic.co/guide/en/security/8.15/security-apis.html).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-09-17 12:24:07 +01:00
Maxim Palenov
a4fc565333
[Security Solution] Align operationId and file names in OpenAPI specs (#189703)
**Relates to:** https://github.com/elastic/kibana/issues/183661 (internal)
**Relates to:** https://github.com/elastic/kibana/issues/183821 (internal)
**Relates to:** https://github.com/elastic/kibana/issues/183837 (internal)

## Summary

It addresses a discussion Rule Management team had on a tech time meeting whose outcome was usage of consistent  operationId, files and folder naming related to OpenAPI specs. For example use `Read` instead of `Get` since it gives better readability and matches with already used approach.

This PR aligns the naming and performs necessary renaming.
2024-08-05 18:11:54 +02:00
Maxim Palenov
845dd1fabb
[Security Solution] Add tags by OpenAPI bundler (#189621)
**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
```
2024-08-02 16:41:49 +02:00
Maxim Palenov
3732d88680
[Security Solution] Implement shared components conflict resolution functionality (#188812)
**Resolves:** https://github.com/elastic/kibana/issues/188817

## Summary

This PR adds automatic shared components conflict resolution functionality for OpenAPI merger. It boils down to a similar result as `npx @redocly/cli join --prefix-components-with-info-prop title` produces by prefixing shared components with document's title in each source.

OpenAPI bundler intentionally won't solve conflicts automatically since it's focused on bundling domain APIs where conflicts are usually indicators of upstream problems.

## Details

While working with various OpenAPI specs it may happen that different specs use exactly the same name for some shared components but different definitions. It must be avoided inside one API domain but it's a usual situation when merging OpenAPI specs of different API domains. For example domains may define a shared `Id` or `404Response` schemas where `Id` is a string in one domain and a number in another.

OpenAPI merger implemented in https://github.com/elastic/kibana/pull/188110 and OpenAPI bundler implemented in https://github.com/elastic/kibana/pull/171526 do not solve shared components related conflicts automatically. It works perfectly for a single API domain forcing engineers choosing shared schema names carefully. 

This PR adds automatic shared components conflict resolution for OpenAPI merger. It prefixes shared component names with a normalized document's title.

OpenAPI bundler intentionally won't solve conflicts automatically since it's focused on bundling domain APIs where conflicts are usually indicators of upstream problems.

## Example

Consider two following OpenAPI specs each defining local `MySchema`

**spec1.schema.yaml**
```yaml
openapi: 3.0.3
info:
  title: My endpoint
  version: '2023-10-31'
paths:
  /api/some_api:
    get:
      operationId: MyEndpointGet
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MySchema'

components:
  schemas:
    MySchema:
      type: string
      enum:
        - value1
```

**spec2.schema.yaml**
```yaml
openapi: 3.0.3
info:
  title: My another endpoint
  version: '2023-10-31'
paths:
  /api/another_api:
    get:
      operationId: MyAnotherEndpointGet
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MySchema'

components:
  schemas:
    MySchema:
      type: number
```

and a script to merge them

```js
require('../../src/setup_node_env');
const { resolve } = require('path');
const { merge } = require('@kbn/openapi-bundler');
const { REPO_ROOT } = require('@kbn/repo-info');

(async () => {
  await merge({
    sourceGlobs: [
      `${REPO_ROOT}/oas_docs/spec1.schema.yaml`,
      `${REPO_ROOT}/oas_docs/spec2.schema.yaml`,
    ],
    outputFilePath: resolve(`${REPO_ROOT}/oas_docs/merged.yaml`),
    options: {
      mergedSpecInfo: {
        title: 'Merge result',
        version: 'my version',
      },
    },
  });
})();
```

will be merged successfully to

**merged.yaml**
```yaml
openapi: 3.0.3
info:
  title: Merge result
  version: 'my version' 
paths:
  /api/another_api:
    get:
      operationId: MyAnotherEndpointGet
      responses:
        '200':
          content:
            application/json; Elastic-Api-Version=2023-10-31:
              schema:
                $ref: '#/components/schemas/My_another_endpoint_MySchema'
  /api/some_api:
    get:
      operationId: MyEndpointGet
      responses:
        '200':
          content:
            application/json; Elastic-Api-Version=2023-10-31:
              schema:
                $ref: '#/components/schemas/My_endpoint_MySchema'
components:
  schemas:
    My_another_endpoint_MySchema:
      type: number
    My_endpoint_MySchema:
      enum:
        - value1
      type: string
```
2024-07-25 12:33:17 -05:00
Maxim Palenov
c76f68e55c
[Security Solution] Auto-bundle Lists API OpenAPI specs (#188407)
**Addresses**: https://github.com/elastic/kibana/issues/184428

## Summary

This PR adds scripts for automatic bundling of Lists API OpenAPI specs as a part of PR pipeline. Corresponding resulting bundles are automatically committed in the Lists common package `kbn-securitysolution-lists-common` in the `docs/openapi/ess/` and `docs/openapi/serverless` folders (similar to https://github.com/elastic/kibana/pull/186384).
2024-07-18 13:33:53 +02:00