Skip to content

Commit

Permalink
[Fleet] Fix Fleet OpenAPI errors (#150583)
Browse files Browse the repository at this point in the history
## Summary

Fixes #149990

There's still plenty of warnings to clean up, and I think we should file
a separate issue to follow up on them. Missing descriptions, empty tags,
etc are things we can certainly clean up ahead of the API being labeled
as GA, they'll just be a little time consuming to track down.

The goal of this PR is simply to remove the `error` level output from
the linters as specified in the linked issue.

## To test

I've added some convenience scripts in
`x-pack/plugins/fleet/package.json` to make working with the OpenAPI
spec easier. You can view the lint output of the built `bundled.yaml` or
`bundled.json` file by running the following:

```
$ # From Kibana root
$ cd x-pack/plugins/fleet

# Runs redocly linter
$ yarn openapi:lint

# Runs speccy
$ yarn openapi:speccy
```

If you need to rebuild the `bundled` spec files, there's a script now as
well:

```
$ yarn openapi:build
```

Redocly reports 89 warnings and no errors, which should suffice in
resolving the linked issue.

cc @lcawl

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
kpollich and kibanamachine authored Feb 9, 2023
1 parent 3b6ae1c commit d0b0985
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
16 changes: 14 additions & 2 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,10 @@
"parameters": [
{
"schema": {
"type": "array"
"type": "array",
"items": {
"type": "string"
}
},
"name": "agentsIds",
"in": "query",
Expand Down Expand Up @@ -1719,6 +1722,14 @@
},
"/agents/{agentId}/actions/{actionId}/cancel": {
"parameters": [
{
"schema": {
"type": "string"
},
"name": "agentId",
"in": "path",
"required": true
},
{
"schema": {
"type": "string"
Expand Down Expand Up @@ -4602,7 +4613,8 @@
},
"in": "header",
"name": "kbn-xsrf",
"required": true
"required": true,
"description": "Kibana's anti Cross-Site Request Forgery token. Can be any string value."
},
"page_size": {
"name": "perPage",
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@ paths:
parameters:
- schema:
type: array
items:
type: string
name: agentsIds
in: query
required: true
Expand Down Expand Up @@ -1071,6 +1073,11 @@ paths:
$ref: '#/components/schemas/agent_action'
/agents/{agentId}/actions/{actionId}/cancel:
parameters:
- schema:
type: string
name: agentId
in: path
required: true
- schema:
type: string
name: actionId
Expand Down Expand Up @@ -2858,6 +2865,7 @@ components:
in: header
name: kbn-xsrf
required: true
description: Kibana's anti Cross-Site Request Forgery token. Can be any string value.
page_size:
name: perPage
in: query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ schema:
in: header
name: kbn-xsrf
required: true
description: Kibana's anti Cross-Site Request Forgery token. Can be any string value.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ get:
parameters:
- schema:
type: array
items:
type: string
name: agentsIds
in: query
required: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
parameters:
- schema:
type: string
name: agentId
in: path
required: true
- schema:
type: string
name: actionId
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/fleet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"cypress:run": "yarn cypress:run:reporter --browser chrome --spec './cypress/e2e/**/*.cy.ts'; status=$?; yarn junit:merge && exit $status",
"cypress:run-as-ci": "node ../../../scripts/functional_tests --config ../../test/fleet_cypress/cli_config.ts",
"cypress:run:reporter": "yarn cypress run --config-file ./cypress.config.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json",
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-fleet/cypress/results/mochawesome*.json > ../../../target/kibana-fleet/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-fleet/cypress/results/output.json --reportDir ../../../target/kibana-fleet/cypress/results && mkdir -p ../../../target/junit && cp ../../../target/kibana-fleet/cypress/results/*.xml ../../../target/junit/"
"junit:merge": "../../../node_modules/.bin/mochawesome-merge ../../../target/kibana-fleet/cypress/results/mochawesome*.json > ../../../target/kibana-fleet/cypress/results/output.json && ../../../node_modules/.bin/marge ../../../target/kibana-fleet/cypress/results/output.json --reportDir ../../../target/kibana-fleet/cypress/results && mkdir -p ../../../target/junit && cp ../../../target/kibana-fleet/cypress/results/*.xml ../../../target/junit/",
"openapi:build": "npx @redocly/openapi-cli bundle --ext yaml --output ./common/openapi/bundled.yaml ./common/openapi/entrypoint.yaml && npx @redocly/openapi-cli bundle --ext json --output ./common/openapi/bundled.json ./common/openapi/entrypoint.yaml",
"openapi:lint": "npx @redocly/cli lint ./common/openapi/bundled.yaml",
"openapi:speccy": "npx speccy lint ./common/openapi/bundled.yaml"
}
}

0 comments on commit d0b0985

Please sign in to comment.