Commit 52abebf
[Fleet] remove old bundled.yaml from oas, fixed tags (#194788)
## 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}/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>1 parent c392aba commit 52abebf
178 files changed
Lines changed: 191998 additions & 75156 deletions
File tree
- .buildkite/scripts/steps
- oas_docs
- output
- scripts
- x-pack/plugins/fleet
- common/openapi
- components
- headers
- parameters
- responses
- schemas
- paths
- server
- routes
- agent_policy
- agent
- app
- data_streams
- download_source
- enrollment_api_key
- epm
- fleet_proxies
- fleet_server_hosts
- health_check
- message_signing_service
- output
- types/rest_spec
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
0 commit comments