Skip to content

Commit c14722b

Browse files
lcawlmaximpn
andauthored
[8.19] [DOCS] Fix OpenAPI linting error in detection_engine (#248570) (#250278)
# Backport This will backport the following commits from `main` to `8.19`: - [[DOCS] Fix OpenAPI linting error in detection_engine (#248570)](#248570) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Lisa Cawley","email":"lcawley@elastic.co"},"sourceCommit":{"committedDate":"2026-01-23T10:04:15Z","message":"[DOCS] Fix OpenAPI linting error in detection_engine (#248570)\n\nCo-authored-by: Maxim Palenov <maxim.palenov@elastic.co>","sha":"da6bf3ecab9d48b569d444f81c2e037cd4404cec","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","docs","Team:Detection Engine","backport:version","v9.3.0","v9.4.0","v8.19.10"],"title":"[DOCS] Fix OpenAPI linting error in detection_engine","number":248570,"url":"https://github.com/elastic/kibana/pull/248570","mergeCommit":{"message":"[DOCS] Fix OpenAPI linting error in detection_engine (#248570)\n\nCo-authored-by: Maxim Palenov <maxim.palenov@elastic.co>","sha":"da6bf3ecab9d48b569d444f81c2e037cd4404cec"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","8.19"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248570","number":248570,"mergeCommit":{"message":"[DOCS] Fix OpenAPI linting error in detection_engine (#248570)\n\nCo-authored-by: Maxim Palenov <maxim.palenov@elastic.co>","sha":"da6bf3ecab9d48b569d444f81c2e037cd4404cec"}},{"branch":"8.19","label":"v8.19.10","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
1 parent 26df6b6 commit c14722b

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/platform/packages/shared/kbn-openapi-generator/redocly_linter/config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins:
44
- extra_linter_rules_plugin.js
55

66
rules:
7-
spec: error
87
spec-strict-refs: error
98
no-path-trailing-slash: error
109
no-identical-paths: error
@@ -20,6 +19,11 @@ rules:
2019
operation-operationId-url-safe: error
2120
operation-parameters-unique: error
2221
extra-linter-rules-plugin/valid-x-modify: error
22+
no-duplicated-tag-names: error
23+
no-example-value-and-externalValue: error
24+
no-undefined-server-variable: error
25+
nullable-type-sibling: error
26+
spec-components-invalid-map-name: error
2327
# Disable rules generating the majority of warnings.
2428
# They will be handled separately.
2529
# operation-description: warn

src/platform/packages/shared/kbn-openapi-generator/src/parser/lib/helpers/find_refs.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ import { traverseObject } from './traverse_object';
1919
export function findRefs(obj: unknown): string[] {
2020
const refs: string[] = [];
2121

22-
traverseObject(obj, (element) => {
23-
if (hasRef(element)) {
24-
refs.push(element.$ref);
22+
traverseObject(
23+
obj,
24+
(element) => {
25+
if (hasRef(element)) {
26+
refs.push(element.$ref);
27+
}
28+
},
29+
{
30+
// We don't require example references in code generation
31+
skipKeys: ['examples'],
2532
}
26-
});
33+
);
2734

2835
return refs;
2936
}

src/platform/packages/shared/kbn-openapi-generator/src/parser/lib/helpers/traverse_object.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,30 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
interface TraverseObjectOptions {
11+
skipKeys?: string[];
12+
}
13+
1014
/**
1115
* A generic function to traverse an object or array of objects recursively
1216
*
1317
* @param obj The object to traverse
1418
* @param onVisit A function that will be called for each traversed node in the object
1519
*/
16-
export function traverseObject(obj: unknown, onVisit: (element: object) => void) {
20+
export function traverseObject(
21+
obj: unknown,
22+
onVisit: (element: object) => void,
23+
options: TraverseObjectOptions = {}
24+
) {
1725
function search(element: unknown) {
1826
if (typeof element === 'object' && element !== null) {
1927
onVisit(element);
2028

21-
Object.values(element).forEach((value) => {
29+
Object.entries(element).forEach(([key, value]) => {
30+
if (options.skipKeys?.includes(key)) {
31+
return;
32+
}
33+
2234
if (Array.isArray(value)) {
2335
value.forEach(search);
2436
} else {

0 commit comments

Comments
 (0)