Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generated/kbapi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SHELL := /bin/bash
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

github_ref ?= f1d0789f0c7b9a46dc35e6dfc72dba2216edb3ae
github_ref ?= c99d51cf47585e53277092f7678cf33c8e279ef7
oas_url := https://raw.githubusercontent.com/elastic/kibana/$(github_ref)/oas_docs/output/kibana.yaml

.PHONY: all
Expand Down
1,098 changes: 832 additions & 266 deletions generated/kbapi/kibana.gen.go

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions generated/kbapi/transform_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ var transformers = []TransformFunc{
fixGetSpacesParams,
fixGetSyntheticsMonitorsParams,
fixGetMaintenanceWindowFindParams,
removeDuplicateOneOfRefs,
transformRemoveExamples,
transformRemoveUnusedComponents,
transformOmitEmptyNullable,
Expand Down Expand Up @@ -881,6 +882,7 @@ func removeBrokenDiscriminator(schema *Schema) {
"Security_Detections_API_RuleSource",
"Security_Endpoint_Exceptions_API_ExceptionListItemEntry",
"Security_Exceptions_API_ExceptionListItemEntry",
"Security_Endpoint_Management_API_ActionDetailsResponse",
}

for _, component := range brokenDiscriminatorComponents {
Expand Down Expand Up @@ -915,6 +917,50 @@ func fixGetMaintenanceWindowFindParams(schema *Schema) {
schema.MustGetPath("/api/maintenance_window/_find").MustGetEndpoint("get").Move("parameters.2.schema.anyOf.1", "parameters.2.schema")
}

func removeDuplicateOneOfRefs(schema *Schema) {
componentSchemas := schema.Components.MustGetMap("schemas")
componentSchemas.Iterate(removeDuplicateOneOfRefsFromNode)
}

// https://github.com/elastic/kibana/issues/244264
func removeDuplicateOneOfRefsFromNode(key string, node Map) {
maybeOneOf, hasOneOf := node.GetSlice("oneOf")
if hasOneOf {
// Check for duplicate $ref entries
seenRefs := map[string]bool{}
newOneOf := Slice{}
for _, item := range maybeOneOf {
itemMap, ok := item.(Map)
if !ok {
newOneOf = append(newOneOf, item)
continue
}
refValue, hasRef := itemMap["$ref"]
if hasRef {
refStr, ok := refValue.(string)
if !ok {
newOneOf = append(newOneOf, item)
continue
}
if _, seen := seenRefs[refStr]; seen {
// Duplicate found, skip it
continue
}
seenRefs[refStr] = true
}
newOneOf = append(newOneOf, item)
}
node["oneOf"] = newOneOf
}

properties, hasProperties := node.GetMap("properties")
if !hasProperties {
return
}

properties.Iterate(removeDuplicateOneOfRefsFromNode)
}

// transformFleetPaths fixes the fleet paths.
func transformFleetPaths(schema *Schema) {
// Agent policies
Expand Down
Loading