[Fleet] remove old bundled.yaml from oas, fixed tags#194788
Merged
juliaElastic merged 16 commits intoelastic:mainfrom Oct 7, 2024
Merged
[Fleet] remove old bundled.yaml from oas, fixed tags#194788juliaElastic merged 16 commits intoelastic:mainfrom
juliaElastic merged 16 commits intoelastic:mainfrom
Conversation
Contributor
|
Pinging @elastic/fleet (Team:Fleet) |
Member
|
Thanks for adding the deprecations and for taking care of this migration! Could you add a quick explanation on the readme on how to use this new system for the openapi, the commands etc? It's fine on another PR as well. Also, is already possible to delete the old openapi specs after this PR is merged? |
criamico
reviewed
Oct 3, 2024
| # OpenAPI | ||
|
|
||
| The current self-contained spec file, available [as JSON](https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/fleet/common/openapi/bundled.json) or [as YAML](https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/fleet/common/openapi/bundled.yaml), can be used for online tools like those found at https://openapi.tools/. | ||
| There is a new way to generate openapi docs from the route definition in code. |
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --update'
10 tasks
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/fleet --update'
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/fleet --update'
jbudz
approved these changes
Oct 3, 2024
Contributor
jbudz
left a comment
There was a problem hiding this comment.
.buildkite/scripts/steps/capture_oas_snapshot.sh
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --update'
lcawl
approved these changes
Oct 3, 2024
Contributor
lcawl
left a comment
There was a problem hiding this comment.
There are linting messages about missing descriptions for responses, for example, but IMO those can be added over time. LGTM
10 tasks
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
tiansivive
pushed a commit
to tiansivive/kibana
that referenced
this pull request
Oct 7, 2024
## Summary Closes elastic#184685 **Release notes**: These schema changes shouldn't be breaking, but there were some incorrect/missing response schemas in the old openapi spec. For example the API `POST /api/fleet/agents/{agentId}/actions` response was incorrectly documented: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/main/x-pack/plugins/fleet/common/openapi/bundled.json#/Elastic%20Agent%20actions/new-agent-action ``` { "body": [ 0 ], "statusCode": 0, "headers": "string" } ``` Fixed here: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/31f8cfd6efc5e79255fec0dfbc1f735592736dad/oas_docs/bundle.json#/Elastic%20Agent%20actions/%252Fapi%252Ffleet%252Fagents%252F%257BagentId%257D%252Factions%230 ``` { "item": { "ack_data": "string", "agents": [ "string" ], "created_at": "string", "data": "string", "expiration": "string", "id": "string", "minimum_execution_duration": 0, "namespaces": [ "string" ], "rollout_duration_seconds": 0, "sent_at": "string", "source_uri": "string", "start_time": "string", "total": 0, "type": "string" } } ``` The new spec should match the implementation accurately, and responses are being verified when returned. Tests were added to make sure the response schemas are correct. If there are any bugs in the current schema, it will result in a HTTP 500 error with an error message on where the schema validation failed. Example of an error where a field is missing: ``` { "statusCode": 500, "error": "Internal Server Error", "message": "Failed output validation: [request body.items.0.name]: definition for this key is missing" } ``` Example of an error where a field is mandatory in the schema, but not provided in the response (missing `schema.maybe`) ``` { "statusCode": 500, "error": "Internal Server Error", "message": "Failed output validation: [request body.items.0.internal]: expected value of type [boolean] but got [undefined]" } ``` There are a few places where the validation allows unknown fields. Used it where some fields were not included in TS types or fields are more dynamic, e.g. fields coming from packages or elasticsearch settings. https://github.com/search?q=repo%3Aelastic%2Fkibana+extendsDeep+path%3A%2F%5Ex-pack%5C%2Fplugins%5C%2Ffleet%5C%2Fserver%5C%2Ftypes%5C%2F%2F&type=code ``` .extendsDeep({ unknowns: 'allow', }) ``` Changes in this pr: Remove using old `bundled.yaml` to generate oas, fixed tags. Removed old openapi files, updated readme. Here is the new bundle in Swagger UI: [stateful](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/31f8cfd6efc5e79255fec0dfbc1f735592736dad/oas_docs/bundle.json) [serverless](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/da72ee0093c5a1e164b4a24c5f94333c2376e7cc/oas_docs/bundle.serverless.json) Updated serverless scripts too. Updated Fleet readme: https://github.com/elastic/kibana/blob/da72ee0093c5a1e164b4a24c5f94333c2376e7cc/x-pack/plugins/fleet/common/openapi/README.md Generated the new bundle by running this script locally: ``` node scripts/capture_oas_snapshot --include-path /api/fleet --update ``` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #184685
Release notes: These schema changes shouldn't be breaking, but there were some incorrect/missing response schemas in the old openapi spec.
For example the API
POST /api/fleet/agents/{agentId}/actionsresponse was incorrectly documented: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/main/x-pack/plugins/fleet/common/openapi/bundled.json#/Elastic%20Agent%20actions/new-agent-actionFixed here: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/31f8cfd6efc5e79255fec0dfbc1f735592736dad/oas_docs/bundle.json#/Elastic%20Agent%20actions/%252Fapi%252Ffleet%252Fagents%252F%257BagentId%257D%252Factions%230
Note: Since the schema changes are only included in
mainbranch (9.x) currently, changing to the openapi spec have to be manually done in the old files in the8.xbranch for backports.The new spec should match the implementation accurately, and responses are being verified when returned. Tests were added to make sure the response schemas are correct.
If there are any bugs in the current schema, it will result in a HTTP 500 error with an error message on where the schema validation failed.
Example of an error where a field is missing:
Example of an error where a field is mandatory in the schema, but not provided in the response (missing
schema.maybe)There are a few places where the validation allows unknown fields. Used it where some fields were not included in TS types or fields are more dynamic, e.g. fields coming from packages or elasticsearch settings.
https://github.com/search?q=repo%3Aelastic%2Fkibana+extendsDeep+path%3A%2F%5Ex-pack%5C%2Fplugins%5C%2Ffleet%5C%2Fserver%5C%2Ftypes%5C%2F%2F&type=code
Changes in this pr:
Remove using old
bundled.yamlto generate oas, fixed tags.Removed old openapi files, updated readme.
Here is the new bundle in Swagger UI:
stateful
serverless
Updated serverless scripts too.
Updated Fleet readme: https://github.com/elastic/kibana/blob/da72ee0093c5a1e164b4a24c5f94333c2376e7cc/x-pack/plugins/fleet/common/openapi/README.md
Generated the new bundle by running this script locally: