diff --git a/lib/trento_web/openapi/v1/schema/discovery_event.ex b/lib/trento_web/openapi/v1/schema/discovery_event.ex index 0ef0b78f49..ea1365a4b1 100644 --- a/lib/trento_web/openapi/v1/schema/discovery_event.ex +++ b/lib/trento_web/openapi/v1/schema/discovery_event.ex @@ -14,6 +14,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.DiscoveryEvent do agent_id: %Schema{type: :string, format: :uuid}, discovery_type: %Schema{type: :string}, payload: %Schema{ + nullable: true, oneOf: [%Schema{type: :object}, %Schema{type: :array}] } }, diff --git a/test/trento_web/controllers/v1/discovery_controller_test.exs b/test/trento_web/controllers/v1/discovery_controller_test.exs index 9fb466d5a5..91c63c7231 100644 --- a/test/trento_web/controllers/v1/discovery_controller_test.exs +++ b/test/trento_web/controllers/v1/discovery_controller_test.exs @@ -20,5 +20,17 @@ defmodule TrentoWeb.V1.DiscoveryControllerTest do ] } = resp end + + test "collect action should accept nil payloads", + %{conn: conn} do + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/collect", %{ + "discovery_type" => "ha_cluster_discovery", + "agent_id" => UUID.uuid4(), + "payload" => nil + }) + |> json_response(202) + end end end