Skip to content

Conversation

@jfsiii
Copy link
Contributor

@jfsiii jfsiii commented Oct 9, 2020

Summary

replaces #77378
fixes #77290

  • Replace the 4000+ line spec_oas3.json file with one ~75 line overview file entrypoint.yaml which imports the various pieces from other directories.
  • Switched from JSON to YAML for "source" files because they're less noisy & more human-friendly. package-registry & package-spec both define specs in YAML as well. We can always convert them to JS for any library that needs it.

Dev docs

New structure

openapi/
├── README.md
├── bundled.json
├── bundled.yaml
├── components/
├── entrypoint.yaml
└── paths/

There are README.md files in openapi, openapi/components, & openapi/paths with information about the purpose, conventions, decisions, etc for that directory

  • entrypoint.yaml is the overview file which links to the various files on disk.

  • bundled.{yaml,json} is the resolved output of that entry & other files in a single file.

    how these were generated (requires node 12+)
    nvm use 12;
    npx @redocly/openapi-cli bundle entrypoint.yaml -o bundled.json
    npx @redocly/openapi-cli bundle entrypoint.yaml -o bundled.yaml
    
    How to generate with node 10+
    npx swagger-cli bundle -o bundled.json -t json entrypoint.yaml
    npx swagger-cli bundle -o bundled.yaml -t yaml entrypoint.yaml
    
  • Paths: Started with a flat paths directory with each path in a separate file. We can move on to a nested file-per-operation like [Ingest Manager] Split OpenAPI spec into multiple files #77378 or any other approach later

    tree ./paths
    paths/
    ├── README.md
    ├── agent_policies.yaml
    ├── [email protected]
    ├── agent_policies@{agent_policy_id}.yaml
    ├── agent_policies@{agent_policy_id}@copy.yaml
    ├── agent_status.yaml
    ├── agents.yaml
    ├── agents@bulk_upgrade.yaml
    ├── [email protected]
    ├── [email protected]
    ├── agents@{agent_id}.yaml
    ├── agents@{agent_id}@acks.yaml
    ├── agents@{agent_id}@checkin.yaml
    ├── agents@{agent_id}@events.yaml
    ├── agents@{agent_id}@unenroll.yaml
    ├── agents@{agent_id}@upgrade.yaml
    ├── enrollment_api_keys.yaml
    ├── enrollment_api_keys@{key_id}.yaml
    ├── [email protected]
    ├── [email protected]
    ├── epm@packages@{pkgkey}.yaml
    ├── install@{os_type}.yaml
    ├── package_policies.yaml
    ├── package_policies@{package_policy_id}.yaml
    └── setup.yaml
    
  • Components: Reusable components like schemas, responses parameters, etc

    tree ./components
    components/
    ├── README.md
    ├── callbacks
    ├── examples
    ├── headers
    │   └── kbn_xsrf.yaml
    ├── links
    ├── parameters
    │   ├── kuery.yaml
    │   ├── page_index.yaml
    │   └── page_size.yaml
    ├── request_bodies
    ├── responses
    ├── schemas
    │   ├── access_api_key.yaml
    │   ├── agent.yaml
    │   ├── agent_event.yaml
    │   ├── agent_metadata.yaml
    │   ├── agent_policy.yaml
    │   ├── agent_status.yaml
    │   ├── agent_type.yaml
    │   ├── bulk_upgrade_agents.yaml
    │   ├── enrollment_api_key.yaml
    │   ├── new_agent_event.yaml
    │   ├── new_agent_policy.yaml
    │   ├── new_package_policy.yaml
    │   ├── package_info.yaml
    │   ├── package_policy.yaml
    │   ├── search_result.yaml
    │   └── upgrade_agent.yaml
    └── security_schemes
    

@jfsiii jfsiii self-assigned this Oct 12, 2020
@jfsiii jfsiii added the Team:Fleet Team label for Observability Data Collection Fleet team label Oct 12, 2020
@jfsiii jfsiii marked this pull request as ready for review October 12, 2020 19:10
@jfsiii jfsiii requested a review from a team October 12, 2020 19:10
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

@jfsiii
Copy link
Contributor Author

jfsiii commented Oct 12, 2020

cc @EricDavisX There's still an easy-to-paste single file at bundled.json

but now there's also a way to link to a more focused spec file like agents@{agent_id}@checkin.yaml

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

distributable file count

id before after diff
default 48447 48493 +46

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@EricDavisX
Copy link
Contributor

this is super cool John - nice work.

Copy link
Contributor

@skh skh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much easier to comprehend now, great change! 👍

@jfsiii jfsiii added v8.0.0 v7.11.0 release_note:skip Skip the PR/issue when compiling release notes labels Oct 13, 2020
@jfsiii jfsiii merged commit 2af36ed into elastic:master Oct 13, 2020
jloleysens added a commit to jloleysens/kibana that referenced this pull request Oct 13, 2020
…otphase-to-formlib

* 'master' of github.com:elastic/kibana: (59 commits)
  [Security Solution][Resolver] Replace copy-to-clipboard with native navigator.clipboard (elastic#80193)
  [Security Solution] Reduce initial bundle size (elastic#78992)
  [Security Solution][Resolver] Fix Resize node box-shadow bug (elastic#80223)
  Move observability content (elastic#79978)
  skip flaky suite (elastic#79389)
  removing kibana_datatable` in favor of `datatable` (elastic#75184)
  [ML] Fixes for anomaly swim lane  (elastic#80299)
  [Lens] Smokescreen lens test unskip (elastic#80190)
  Improved AlertsClient tests structure by splitting a huge alerts_client.tests.ts file into a specific files defined by its responsibility. (elastic#80088)
  [APM] React key warning when opening popover with external resources (elastic#80328)
  [Step 1] use Observables on server search API (elastic#79874)
  Apply back pressure in Task Manager whenever Elasticsearch responds with a 429 (elastic#75666)
  [Lens] Leverage original http request error (elastic#79831)
  [Security Solution][Case] Improve ServiceConnectorCaseParams type (elastic#80109)
  [SECURITY_SOLUTION] Fix query on alert histogram (elastic#80219)
  [DOCS] Update ingest node pipelines doc (elastic#79187)
  [Ingest Manager] Split up OpenAPI spec file  (elastic#80107)
  [SECURITY_SOLUTION][ENDPOINT] Fix label on Trusted App create name field (elastic#80001)
  [Ingest Manager] Fix agent policy bump revision to create only one POLICY_CHANGE action (elastic#80081)
  Grid layout fixes (elastic#80305)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared/data_tier_allocation_field.tsx
#	x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
jfsiii pushed a commit that referenced this pull request Oct 13, 2020
## Summary

replaces #77378 
fixes #77290

 * Replace the 4000+ line `spec_oas3.json` file with one ~75 line overview file `entrypoint.yaml` which imports the various pieces from other directories.
 * Switched from JSON to YAML for "source" files because they're less noisy & more human-friendly. `package-registry` & `package-spec` both define specs in YAML as well. We can always convert them to JS for any library that needs it.



## Dev docs
### New structure

```
openapi/
├── README.md
├── bundled.json
├── bundled.yaml
├── components/
├── entrypoint.yaml
└── paths/
```

There are `README.md` files in `openapi`, `openapi/components`, & `openapi/paths` with information about the purpose, conventions, decisions, etc for that directory

* `entrypoint.yaml` is the overview file which links to the various files on disk.
* `bundled.{yaml,json}` is the resolved output of that entry & other files in a single file. 
    <details><summary>how these were generated (requires node 12+)</summary>

    ```
    nvm use 12;
    npx @redocly/openapi-cli bundle entrypoint.yaml -o bundled.json
    npx @redocly/openapi-cli bundle entrypoint.yaml -o bundled.yaml
    ```
    </details>

    <details><summary>How to generate with node 10+</summary>

    ```
    npx swagger-cli bundle -o bundled.json -t json entrypoint.yaml
    npx swagger-cli bundle -o bundled.yaml -t yaml entrypoint.yaml
    ```
    </details>

 * [Paths](paths/README.md): Started with a flat `paths` directory with each path in a separate file. We can move on to a nested file-per-operation like #77378 or any other approach later

    <details><summary><code>tree ./paths</code></summary>

    ```
    paths/
    ├── README.md
    ├── agent_policies.yaml
    ├── [email protected]
    ├── agent_policies@{agent_policy_id}.yaml
    ├── agent_policies@{agent_policy_id}@copy.yaml
    ├── agent_status.yaml
    ├── agents.yaml
    ├── agents@bulk_upgrade.yaml
    ├── [email protected]
    ├── [email protected]
    ├── agents@{agent_id}.yaml
    ├── agents@{agent_id}@acks.yaml
    ├── agents@{agent_id}@checkin.yaml
    ├── agents@{agent_id}@events.yaml
    ├── agents@{agent_id}@unenroll.yaml
    ├── agents@{agent_id}@upgrade.yaml
    ├── enrollment_api_keys.yaml
    ├── enrollment_api_keys@{key_id}.yaml
    ├── [email protected]
    ├── [email protected]
    ├── epm@packages@{pkgkey}.yaml
    ├── install@{os_type}.yaml
    ├── package_policies.yaml
    ├── package_policies@{package_policy_id}.yaml
    └── setup.yaml
    ```
    </details>

  * [Components](components/README.md): Reusable components like [`schemas`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject), [`responses`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject) [`parameters`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject), etc
    <details><summary><code>tree ./components</code></summary>

    ```
    components/
    ├── README.md
    ├── callbacks
    ├── examples
    ├── headers
    │   └── kbn_xsrf.yaml
    ├── links
    ├── parameters
    │   ├── kuery.yaml
    │   ├── page_index.yaml
    │   └── page_size.yaml
    ├── request_bodies
    ├── responses
    ├── schemas
    │   ├── access_api_key.yaml
    │   ├── agent.yaml
    │   ├── agent_event.yaml
    │   ├── agent_metadata.yaml
    │   ├── agent_policy.yaml
    │   ├── agent_status.yaml
    │   ├── agent_type.yaml
    │   ├── bulk_upgrade_agents.yaml
    │   ├── enrollment_api_key.yaml
    │   ├── new_agent_event.yaml
    │   ├── new_agent_policy.yaml
    │   ├── new_package_policy.yaml
    │   ├── package_info.yaml
    │   ├── package_policy.yaml
    │   ├── search_result.yaml
    │   └── upgrade_agent.yaml
    └── security_schemes
    ```    
</details>
@ph
Copy link
Contributor

ph commented Oct 13, 2020

@jfsiii does this include the added bulk action endpoint and upgrade changes?

@jfsiii
Copy link
Contributor Author

jfsiii commented Oct 13, 2020

@ph no, this was merely breaking up the file. Missing endpoints and other issues are tracked in #79574

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ingest Manager]Split OpenAPI spec file into multiple files

6 participants