[HTTP/OAS] Merge OpenAPI specs by using kbn-openapi-bundler#189262
[HTTP/OAS] Merge OpenAPI specs by using kbn-openapi-bundler#189262maximpn merged 16 commits intoelastic:mainfrom
kbn-openapi-bundler#189262Conversation
|
Pinging @elastic/kibana-core (Team:Core) |
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
cc41f04 to
d625f11
Compare
@kbn/openapi-bundlerkbn-openapi-bundler
d625f11 to
dcc3530
Compare
6d781c3 to
210596e
Compare
590f08e to
fe987df
Compare
jloleysens
left a comment
There was a problem hiding this comment.
Thank you for driving this @maximpn ! I have previewed the output on bump.sh and it's looking mostly good. Left a few comments I'd like to get your thoughts on.
oas_docs/makefile
Outdated
There was a problem hiding this comment.
I think it's good to leave for now since there are some outstanding issues (e.g. some operationIds that are not unique) that need to be resolved before we start publishing the security APIs. We can switch to the new command when those are fixed.
oas_docs/output/kibana.merged.yaml
Outdated
There was a problem hiding this comment.
I see several entries of Elastic-Api-Version with values defined that don't fit the public API contract of a date string. I'm not sure where these values are coming from, could we just fallback to 2023-10-31 if not otherwise defined for all endpoints?
Full set of instances + line nr here
68: application/json; Elastic-Api-Version=0.2:
87: application/json; Elastic-Api-Version=0.2:
160: application/json; Elastic-Api-Version=0.2:
198: application/json; Elastic-Api-Version=0.2:
215: application/json; Elastic-Api-Version=0.2:
247: application/json; Elastic-Api-Version=0.2:
267: application/json; Elastic-Api-Version=0.2:
303: application/json; Elastic-Api-Version=0.2:
384: application/json; Elastic-Api-Version=0.2:
413: application/json; Elastic-Api-Version=0.2:
424: application/json; Elastic-Api-Version=0.2:
444: application/json; Elastic-Api-Version=0.2:
455: application/json; Elastic-Api-Version=0.2:
483: application/json; Elastic-Api-Version=0.2:
515: application/json; Elastic-Api-Version=0.2:
579: application/json; Elastic-Api-Version=0.2:
602: application/json; Elastic-Api-Version=0.2:
647: application/json; Elastic-Api-Version=1.0.0:
664: application/json; Elastic-Api-Version=1.0.0:
696: application/json; Elastic-Api-Version=1.0.0:
719: application/json; Elastic-Api-Version=1.0.0:
790: application/json; Elastic-Api-Version=1.0.0:
1068: application/json; Elastic-Api-Version=0.1:
1095: application/json; Elastic-Api-Version=0.1:
1109: application/json; Elastic-Api-Version=0.1:
1119: application/json; Elastic-Api-Version=0.1:
1125: application/json; Elastic-Api-Version=0.1:
1145: application/json; Elastic-Api-Version=0.1:
1159: application/json; Elastic-Api-Version=0.1:
1168: application/json; Elastic-Api-Version=0.1:
1182: application/json; Elastic-Api-Version=0.1:
1192: application/json; Elastic-Api-Version=0.1:
1198: application/json; Elastic-Api-Version=0.1:
1216: application/json; Elastic-Api-Version=0.1:
1232: application/json; Elastic-Api-Version=0.1:
1241: application/json; Elastic-Api-Version=0.1:
1256: application/json; Elastic-Api-Version=0.1:
1278: application/json; Elastic-Api-Version=0.1:
1298: application/json; Elastic-Api-Version=0.1:
1320: application/json; Elastic-Api-Version=0.1:
1333: application/json; Elastic-Api-Version=0.1:
1351: application/json; Elastic-Api-Version=0.1:
1366: application/json; Elastic-Api-Version=0.1:
1382: application/json; Elastic-Api-Version=0.1:
1396: application/json; Elastic-Api-Version=0.1:
1420: application/json; Elastic-Api-Version=0.1:
1433: application/json; Elastic-Api-Version=0.1:
1446: application/json; Elastic-Api-Version=0.1:
1459: application/json; Elastic-Api-Version=0.1:
1483: application/json; Elastic-Api-Version=0.1:
1492: application/json; Elastic-Api-Version=0.1:
1510: application/json; Elastic-Api-Version=0.1:
1520: application/json; Elastic-Api-Version=0.1:
1556: application/json; Elastic-Api-Version=0.1:
1567: application/json; Elastic-Api-Version=0.1:
3255: application/json; Elastic-Api-Version=0.1:
3289: application/json; Elastic-Api-Version=0.1:
3295: application/json; Elastic-Api-Version=0.1:
7281: application/json; Elastic-Api-Version=1.0.1:
7290: application/json; Elastic-Api-Version=1.0.1:
7820: application/json; Elastic-Api-Version=0.1:
7829: application/json; Elastic-Api-Version=0.1:
7835: application/json; Elastic-Api-Version=0.1:
7869: application/json; Elastic-Api-Version=0.1:
7878: application/json; Elastic-Api-Version=0.1:
7887: application/json; Elastic-Api-Version=0.1:
7902: application/json; Elastic-Api-Version=0.1:
7911: application/json; Elastic-Api-Version=0.1:
7917: application/json; Elastic-Api-Version=0.1:
7940: application/json; Elastic-Api-Version=0.1:
7949: application/json; Elastic-Api-Version=0.1:
7958: application/json; Elastic-Api-Version=0.1:
7974: application/json; Elastic-Api-Version=0.1:
7983: application/json; Elastic-Api-Version=0.1:
7992: application/json; Elastic-Api-Version=0.1:
8024: application/json; Elastic-Api-Version=0.1:
8058: application/x-ndjson; Elastic-Api-Version=0.1:
8068: application/json; Elastic-Api-Version=0.1:
8194: application/json; Elastic-Api-Version=0.1:
8200: application/json; Elastic-Api-Version=0.1:
8259: multipart/form-data; Elastic-Api-Version=0.1:
8278: application/json; Elastic-Api-Version=0.1:
8324: application/json; Elastic-Api-Version=0.1:
8373: multipart/form-data; Elastic-Api-Version=0.1:
8438: application/json; Elastic-Api-Version=0.1:
8482: application/json; Elastic-Api-Version=0.1:
8504: application/json; Elastic-Api-Version=0.1:
8520: application/json; Elastic-Api-Version=0.1:
8526: application/json; Elastic-Api-Version=0.1:
8544: application/json; Elastic-Api-Version=0.1:
8550: application/json; Elastic-Api-Version=0.1:
8574: application/json; Elastic-Api-Version=0.1:
8590: application/json; Elastic-Api-Version=0.1:
8596: application/json; Elastic-Api-Version=0.1:
8613: application/json; Elastic-Api-Version=0.1:
8620: application/json; Elastic-Api-Version=0.1:
8626: application/json; Elastic-Api-Version=0.1:
8632: application/json; Elastic-Api-Version=0.1:
8657: application/json; Elastic-Api-Version=0.1:
8663: application/json; Elastic-Api-Version=0.1:
10132: application/json; Elastic-Api-Version=1.0:
10138: application/json; Elastic-Api-Version=1.0:
10144: application/json; Elastic-Api-Version=1.0:
10150: application/json; Elastic-Api-Version=1.0:
10156: application/json; Elastic-Api-Version=1.0:
10173: application/json; Elastic-Api-Version=1.0:
10180: application/json; Elastic-Api-Version=1.0:
10186: application/json; Elastic-Api-Version=1.0:
10192: application/json; Elastic-Api-Version=1.0:
10198: application/json; Elastic-Api-Version=1.0:
10204: application/json; Elastic-Api-Version=1.0:
10223: application/json; Elastic-Api-Version=1.0:
10232: application/json; Elastic-Api-Version=1.0:
10238: application/json; Elastic-Api-Version=1.0:
10244: application/json; Elastic-Api-Version=1.0:
10266: application/json; Elastic-Api-Version=1.0:
10272: application/json; Elastic-Api-Version=1.0:
10278: application/json; Elastic-Api-Version=1.0:
10284: application/json; Elastic-Api-Version=1.0:
10309: application/json; Elastic-Api-Version=1.0:
10315: application/json; Elastic-Api-Version=1.0:
10321: application/json; Elastic-Api-Version=1.0:
10327: application/json; Elastic-Api-Version=1.0:
10333: application/json; Elastic-Api-Version=1.0:
10351: application/json; Elastic-Api-Version=1.0:
10358: application/json; Elastic-Api-Version=1.0:
10364: application/json; Elastic-Api-Version=1.0:
10370: application/json; Elastic-Api-Version=1.0:
10376: application/json; Elastic-Api-Version=1.0:
10382: application/json; Elastic-Api-Version=1.0:
10402: application/json; Elastic-Api-Version=1.0:
10408: application/json; Elastic-Api-Version=1.0:
10414: application/json; Elastic-Api-Version=1.0:
10420: application/json; Elastic-Api-Version=1.0:
10426: application/json; Elastic-Api-Version=1.0:
10448: application/json; Elastic-Api-Version=1.0:
10454: application/json; Elastic-Api-Version=1.0:
10460: application/json; Elastic-Api-Version=1.0:
10466: application/json; Elastic-Api-Version=1.0:
10488: application/json; Elastic-Api-Version=1.0:
10494: application/json; Elastic-Api-Version=1.0:
10500: application/json; Elastic-Api-Version=1.0:
10506: application/json; Elastic-Api-Version=1.0:
12724: application/json; Elastic-Api-Version=0.2:
12730: application/json; Elastic-Api-Version=0.2:
12750: application/json; Elastic-Api-Version=0.2:
There was a problem hiding this comment.
This is a known issue and there are multiple ways to solve it.
The right way to solve it is say the bundler what version source OpenAPI specs implement. One of the ideas is to use info.x-implementation-version in the source OpenAPI specs as in this example PR.
The simplest approach for now is to fallback to 2023-10-31 when it's impossible to detect an implementation version. It's not future proof since it won't work when new versions pop up.
Security Solution OpenAPI specs use info.version as an implementation version (it works for us since we consider document version equal to implementation version and wanna bump document version when we have incompatible changes). The bundler takes info.version (there are no other known version fields in OpenAPI specs) and uses it for Elastic-Api-Version.
@jloleysens what solution do you prefer?
There was a problem hiding this comment.
The simplest approach for now is to fallback to 2023-10-31 when it's impossible to detect an implementation version. It's not future proof since it won't work when new versions pop up.
IMO this seems OK. In future we can find a way to provide version for a set of specs like a file naming my_api.2024-20-1.yaml or path convention /2024-20-1/my_api.yaml. The default would just be to use the "first" version. WDYT?
There was a problem hiding this comment.
Sounds good for me if @lcawl don't have any objections. I'll make adjustments in this PR (should be few lines change).
In future we can find a way to provide version for a set of specs like a file naming my_api.2024-20-1.yaml or path convention /2024-20-1/my_api.yaml. The default would just be to use the "first" version. WDYT?
Any option (or multiple options) works well if we agree on that across Kibana.
There was a problem hiding this comment.
I think this is difficult to visualize until we start having more than one Elastic-Api-Version value. However it's implemented in the code and the bundler, we'd ideally show all of the header values and their associated request and response bodies in a single document. As long as this PR is moving in that direction, it is sufficient for docs purposes.
5e8af02 to
9385e55
Compare
fc7903e to
4163443
Compare
banderror
left a comment
There was a problem hiding this comment.
Rule Management-owned changes and PR overall LGTM 👍
One weird thing is that GitHub:
- requested a review from @elastic/security-solution which is probably caused by changes in:
x-pack/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml
- but didn't request a review from @elastic/security-detection-rule-management because of changes in:
packages/kbn-openapi-bundler/src/bundler/merge_documents/enrich_with_version_mime_param.tsx-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_crud/bulk_delete_rules/bulk_delete_rules_route.schema.yaml
@maximpn Could you please check if there's anything wrong with the CODEOWNERS file?
Apart from that, thanks for your hard work on Security OpenAPI specs and all the automation tools you created for us and other teams in Security. The progress on that is amazing and the quality of the solution is top-notch, especially considering the tight timelines and the cope of work that we had. Thank you! 👏
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @maximpn |
|
I checked CODEOWNERS file and haven't found anything suspicious. Most probably GitHub's algorithm didn't handle review properly since I made changes to |
…c#189262) **Addresses:** elastic#186356 **Relates to:** elastic#184428 ## Summary This PR adds a merging JS script based on the utility implemented in elastic#186356. Resulted OpenAPI bundle as committed in `oas_docs/output/kibana.serverless.bundled.yaml`. ## Details elastic#188110 implements and exposes `merge` utility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like below ```js const { merge } = require('@kbn/openapi-bundler'); (async () => { await merge({ sourceGlobs: [/* a list of source globs goes here */], outputFilePath: 'path/to/the/output/file.yaml', }); })(); ``` The JS script added in this PR includes source OpenAPI specs presented in `oas_docs/makefile` plus Security Solution OpenAPI specs based on elastic#184428. **To run** the script use the following command from Kibana root folder ```bash node ./oas_docs/scripts/merge_serverless_oas.js ``` ## Known linting issues with Security Solution OpenAPI specs Running Spectral OpenAPI linter on the result bundle shows a number of errors caused by `no-$ref-siblings` rule. This caused by the current code generator implementation which requires `default` property to be set next to `$ref` though it's not correct for OpenAPI `3.0.3` while it's allowed in `3.1`. It seems that Bump.sh handles such cases properly though by properly showing a default value. We need to analyze the problem and decide if/when we should fix it. The rest of warnings look fixable and will be addressed in the next stage after setting up linter rules. ## Next steps Since `@kbn/openapi-bundler` package is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also means `oas_docs/makefile` should be superseded by JS script(s) using `merge` utility form `@kbn/openapi-bundler` package. `@kbn/openapi-bundler` SHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adopting `spectral-cli` for linting purposes.
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…c#189262) **Addresses:** elastic#186356 **Relates to:** elastic#184428 This PR adds a merging JS script based on the utility implemented in elastic#186356. Resulted OpenAPI bundle as committed in `oas_docs/output/kibana.serverless.bundled.yaml`. elastic#188110 implements and exposes `merge` utility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like below ```js const { merge } = require('@kbn/openapi-bundler'); (async () => { await merge({ sourceGlobs: [/* a list of source globs goes here */], outputFilePath: 'path/to/the/output/file.yaml', }); })(); ``` The JS script added in this PR includes source OpenAPI specs presented in `oas_docs/makefile` plus Security Solution OpenAPI specs based on elastic#184428. **To run** the script use the following command from Kibana root folder ```bash node ./oas_docs/scripts/merge_serverless_oas.js ``` Running Spectral OpenAPI linter on the result bundle shows a number of errors caused by `no-$ref-siblings` rule. This caused by the current code generator implementation which requires `default` property to be set next to `$ref` though it's not correct for OpenAPI `3.0.3` while it's allowed in `3.1`. It seems that Bump.sh handles such cases properly though by properly showing a default value. We need to analyze the problem and decide if/when we should fix it. The rest of warnings look fixable and will be addressed in the next stage after setting up linter rules. Since `@kbn/openapi-bundler` package is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also means `oas_docs/makefile` should be superseded by JS script(s) using `merge` utility form `@kbn/openapi-bundler` package. `@kbn/openapi-bundler` SHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adopting `spectral-cli` for linting purposes.
…189262) (#190541) # Backport This will backport the bundler aspects of the following commits from `main` to `8.15`: - [[HTTP/OAS] Merge OpenAPI specs by using `kbn-openapi-bundler` (#189262)](#189262) - #189621 - #189482 - #189348 - #189472 - #188110 - #188812 <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Maxim Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2024-08-13T10:45:35Z","message":"[HTTP/OAS] Merge OpenAPI specs by using `kbn-openapi-bundler` (#189262)\n\n**Addresses:** https://github.com/elastic/kibana/issues/186356\r\n**Relates to:** https://github.com/elastic/kibana/issues/184428\r\n\r\n## Summary\r\n\r\nThis PR adds a merging JS script based on the utility implemented in #186356. Resulted OpenAPI bundle as committed in `oas_docs/output/kibana.serverless.bundled.yaml`.\r\n\r\n## Details\r\n\r\nhttps://github.com//pull/188110 implements and exposes `merge` utility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like below\r\n\r\n```js\r\nconst { merge } = require('@kbn/openapi-bundler');\r\n\r\n(async () => {\r\n await merge({\r\n sourceGlobs: [/* a list of source globs goes here */],\r\n outputFilePath: 'path/to/the/output/file.yaml',\r\n });\r\n})();\r\n```\r\n\r\nThe JS script added in this PR includes source OpenAPI specs presented in `oas_docs/makefile` plus Security Solution OpenAPI specs based on https://github.com/elastic/kibana/issues/184428.\r\n\r\n**To run** the script use the following command from Kibana root folder\r\n\r\n```bash\r\nnode ./oas_docs/scripts/merge_serverless_oas.js \r\n```\r\n\r\n## Known linting issues with Security Solution OpenAPI specs\r\n\r\nRunning Spectral OpenAPI linter on the result bundle shows a number of errors caused by `no-$ref-siblings` rule. This caused by the current code generator implementation which requires `default` property to be set next to `$ref` though it's not correct for OpenAPI `3.0.3` while it's allowed in `3.1`. It seems that Bump.sh handles such cases properly though by properly showing a default value.\r\n\r\nWe need to analyze the problem and decide if/when we should fix it.\r\n\r\nThe rest of warnings look fixable and will be addressed in the next stage after setting up linter rules.\r\n\r\n## Next steps\r\n\r\nSince `@kbn/openapi-bundler` package is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also means `oas_docs/makefile` should be superseded by JS script(s) using `merge` utility form `@kbn/openapi-bundler` package.\r\n\r\n`@kbn/openapi-bundler` SHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adopting `spectral-cli` for linting purposes.","sha":"7a2e7bef9644eaf04fd820d16b8ee137b3c00f2b","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","backport:skip","docs","Team: SecuritySolution","Feature:OAS","v8.16.0"],"number":189262,"url":"https://github.com/elastic/kibana/pull/189262","mergeCommit":{"message":"[HTTP/OAS] Merge OpenAPI specs by using `kbn-openapi-bundler` (#189262)\n\n**Addresses:** https://github.com/elastic/kibana/issues/186356\r\n**Relates to:** https://github.com/elastic/kibana/issues/184428\r\n\r\n## Summary\r\n\r\nThis PR adds a merging JS script based on the utility implemented in #186356. Resulted OpenAPI bundle as committed in `oas_docs/output/kibana.serverless.bundled.yaml`.\r\n\r\n## Details\r\n\r\nhttps://github.com//pull/188110 implements and exposes `merge` utility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like below\r\n\r\n```js\r\nconst { merge } = require('@kbn/openapi-bundler');\r\n\r\n(async () => {\r\n await merge({\r\n sourceGlobs: [/* a list of source globs goes here */],\r\n outputFilePath: 'path/to/the/output/file.yaml',\r\n });\r\n})();\r\n```\r\n\r\nThe JS script added in this PR includes source OpenAPI specs presented in `oas_docs/makefile` plus Security Solution OpenAPI specs based on https://github.com/elastic/kibana/issues/184428.\r\n\r\n**To run** the script use the following command from Kibana root folder\r\n\r\n```bash\r\nnode ./oas_docs/scripts/merge_serverless_oas.js \r\n```\r\n\r\n## Known linting issues with Security Solution OpenAPI specs\r\n\r\nRunning Spectral OpenAPI linter on the result bundle shows a number of errors caused by `no-$ref-siblings` rule. This caused by the current code generator implementation which requires `default` property to be set next to `$ref` though it's not correct for OpenAPI `3.0.3` while it's allowed in `3.1`. It seems that Bump.sh handles such cases properly though by properly showing a default value.\r\n\r\nWe need to analyze the problem and decide if/when we should fix it.\r\n\r\nThe rest of warnings look fixable and will be addressed in the next stage after setting up linter rules.\r\n\r\n## Next steps\r\n\r\nSince `@kbn/openapi-bundler` package is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also means `oas_docs/makefile` should be superseded by JS script(s) using `merge` utility form `@kbn/openapi-bundler` package.\r\n\r\n`@kbn/openapi-bundler` SHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adopting `spectral-cli` for linting purposes.","sha":"7a2e7bef9644eaf04fd820d16b8ee137b3c00f2b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/189262","number":189262,"mergeCommit":{"message":"[HTTP/OAS] Merge OpenAPI specs by using `kbn-openapi-bundler` (#189262)\n\n**Addresses:** https://github.com/elastic/kibana/issues/186356\r\n**Relates to:** https://github.com/elastic/kibana/issues/184428\r\n\r\n## Summary\r\n\r\nThis PR adds a merging JS script based on the utility implemented in #186356. Resulted OpenAPI bundle as committed in `oas_docs/output/kibana.serverless.bundled.yaml`.\r\n\r\n## Details\r\n\r\nhttps://github.com//pull/188110 implements and exposes `merge` utility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like below\r\n\r\n```js\r\nconst { merge } = require('@kbn/openapi-bundler');\r\n\r\n(async () => {\r\n await merge({\r\n sourceGlobs: [/* a list of source globs goes here */],\r\n outputFilePath: 'path/to/the/output/file.yaml',\r\n });\r\n})();\r\n```\r\n\r\nThe JS script added in this PR includes source OpenAPI specs presented in `oas_docs/makefile` plus Security Solution OpenAPI specs based on https://github.com/elastic/kibana/issues/184428.\r\n\r\n**To run** the script use the following command from Kibana root folder\r\n\r\n```bash\r\nnode ./oas_docs/scripts/merge_serverless_oas.js \r\n```\r\n\r\n## Known linting issues with Security Solution OpenAPI specs\r\n\r\nRunning Spectral OpenAPI linter on the result bundle shows a number of errors caused by `no-$ref-siblings` rule. This caused by the current code generator implementation which requires `default` property to be set next to `$ref` though it's not correct for OpenAPI `3.0.3` while it's allowed in `3.1`. It seems that Bump.sh handles such cases properly though by properly showing a default value.\r\n\r\nWe need to analyze the problem and decide if/when we should fix it.\r\n\r\nThe rest of warnings look fixable and will be addressed in the next stage after setting up linter rules.\r\n\r\n## Next steps\r\n\r\nSince `@kbn/openapi-bundler` package is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also means `oas_docs/makefile` should be superseded by JS script(s) using `merge` utility form `@kbn/openapi-bundler` package.\r\n\r\n`@kbn/openapi-bundler` SHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adopting `spectral-cli` for linting purposes.","sha":"7a2e7bef9644eaf04fd820d16b8ee137b3c00f2b"}}]}] BACKPORT--> --------- Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
**Relates to:** elastic#189262 ## Summary This PR adds scripts to automatically bundle staging Kibana OpenAPI specs in CI. It's done in a similar way as in elastic#189262. (cherry picked from commit a378064)
# Backport This will backport the following commits from `main` to `8.x`: - [[HTTP/OAS] Auto bundle staging OpenAPI specs (#193402)](#193402) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Maxim Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2024-09-22T07:15:57Z","message":"[HTTP/OAS] Auto bundle staging OpenAPI specs (#193402)\n\n**Relates to:** https://github.com/elastic/kibana/pull/189262\r\n\r\n## Summary\r\n\r\nThis PR adds scripts to automatically bundle staging Kibana OpenAPI specs in CI. It's done in a similar way as in https://github.com/elastic/kibana/pull/189262.","sha":"a3780640060685f699687f1b9b9e55bd798fef07","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","v9.0.0","docs","Team: SecuritySolution","backport:prev-minor","Feature:OAS","v8.16.0"],"title":"[HTTP/OAS] Auto bundle staging OpenAPI specs","number":193402,"url":"https://github.com/elastic/kibana/pull/193402","mergeCommit":{"message":"[HTTP/OAS] Auto bundle staging OpenAPI specs (#193402)\n\n**Relates to:** https://github.com/elastic/kibana/pull/189262\r\n\r\n## Summary\r\n\r\nThis PR adds scripts to automatically bundle staging Kibana OpenAPI specs in CI. It's done in a similar way as in https://github.com/elastic/kibana/pull/189262.","sha":"a3780640060685f699687f1b9b9e55bd798fef07"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193402","number":193402,"mergeCommit":{"message":"[HTTP/OAS] Auto bundle staging OpenAPI specs (#193402)\n\n**Relates to:** https://github.com/elastic/kibana/pull/189262\r\n\r\n## Summary\r\n\r\nThis PR adds scripts to automatically bundle staging Kibana OpenAPI specs in CI. It's done in a similar way as in https://github.com/elastic/kibana/pull/189262.","sha":"a3780640060685f699687f1b9b9e55bd798fef07"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
Addresses: #186356
Relates to: #184428
Summary
This PR adds a merging JS script based on the utility implemented in #186356. Resulted OpenAPI bundle as committed in
oas_docs/output/kibana.serverless.bundled.yaml.Details
#188110 implements and exposes
mergeutility design to merge source OpenAPI specs without processing. It's has only a programmatic API. To merge OpenAPI specs it's required to add a JS script like belowThe JS script added in this PR includes source OpenAPI specs presented in
oas_docs/makefileplus Security Solution OpenAPI specs based on #184428.To run the script use the following command from Kibana root folder
Known linting issues with Security Solution OpenAPI specs
Running Spectral OpenAPI linter on the result bundle shows a number of errors caused by
no-$ref-siblingsrule. This caused by the current code generator implementation which requiresdefaultproperty to be set next to$refthough it's not correct for OpenAPI3.0.3while it's allowed in3.1. It seems that Bump.sh handles such cases properly though by properly showing a default value.We need to analyze the problem and decide if/when we should fix it.
The rest of warnings look fixable and will be addressed in the next stage after setting up linter rules.
Next steps
Since
@kbn/openapi-bundlerpackage is tailored specifically for Kibana it should replace Redocly currently used to merge OpenAPI specs. It also meansoas_docs/makefileshould be superseded by JS script(s) usingmergeutility form@kbn/openapi-bundlerpackage.@kbn/openapi-bundlerSHOULD NOT replace OpenAPI linters since it doesn't perform thorough linting. It's good if we continue adoptingspectral-clifor linting purposes.