Skip to content

Commit 863d7cf

Browse files
chore(deps): update kibana-openapi-spec digest to c99d51c (#1487)
* chore(deps): update kibana-openapi-spec digest to c99d51c * Remove broken discriminator * Fix build * Remove unnecessary cast --------- Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> Co-authored-by: Toby Brain <[email protected]>
1 parent e00b2f3 commit 863d7cf

File tree

15 files changed

+1235
-288
lines changed

15 files changed

+1235
-288
lines changed

generated/kbapi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SHELL := /bin/bash
33
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
44

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

88
.PHONY: all

generated/kbapi/kibana.gen.go

Lines changed: 832 additions & 266 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/kbapi/transform_schema.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ var transformers = []TransformFunc{
567567
fixGetSpacesParams,
568568
fixGetSyntheticsMonitorsParams,
569569
fixGetMaintenanceWindowFindParams,
570+
removeDuplicateOneOfRefs,
570571
transformRemoveExamples,
571572
transformRemoveUnusedComponents,
572573
transformOmitEmptyNullable,
@@ -881,6 +882,7 @@ func removeBrokenDiscriminator(schema *Schema) {
881882
"Security_Detections_API_RuleSource",
882883
"Security_Endpoint_Exceptions_API_ExceptionListItemEntry",
883884
"Security_Exceptions_API_ExceptionListItemEntry",
885+
"Security_Endpoint_Management_API_ActionDetailsResponse",
884886
}
885887

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

920+
func removeDuplicateOneOfRefs(schema *Schema) {
921+
componentSchemas := schema.Components.MustGetMap("schemas")
922+
componentSchemas.Iterate(removeDuplicateOneOfRefsFromNode)
923+
}
924+
925+
// https://github.com/elastic/kibana/issues/244264
926+
func removeDuplicateOneOfRefsFromNode(key string, node Map) {
927+
maybeOneOf, hasOneOf := node.GetSlice("oneOf")
928+
if hasOneOf {
929+
// Check for duplicate $ref entries
930+
seenRefs := map[string]bool{}
931+
newOneOf := Slice{}
932+
for _, item := range maybeOneOf {
933+
itemMap, ok := item.(Map)
934+
if !ok {
935+
newOneOf = append(newOneOf, item)
936+
continue
937+
}
938+
refValue, hasRef := itemMap["$ref"]
939+
if hasRef {
940+
refStr, ok := refValue.(string)
941+
if !ok {
942+
newOneOf = append(newOneOf, item)
943+
continue
944+
}
945+
if _, seen := seenRefs[refStr]; seen {
946+
// Duplicate found, skip it
947+
continue
948+
}
949+
seenRefs[refStr] = true
950+
}
951+
newOneOf = append(newOneOf, item)
952+
}
953+
node["oneOf"] = newOneOf
954+
}
955+
956+
properties, hasProperties := node.GetMap("properties")
957+
if !hasProperties {
958+
return
959+
}
960+
961+
properties.Iterate(removeDuplicateOneOfRefsFromNode)
962+
}
963+
918964
// transformFleetPaths fixes the fleet paths.
919965
func transformFleetPaths(schema *Schema) {
920966
// Agent policies

0 commit comments

Comments
 (0)