File size: 749 Bytes
88211d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
defmodule PlausibleWeb.Plugins.API.Schemas.Goal do
  @moduledoc """
  OpenAPI schema for Goal
  """
  use PlausibleWeb, :open_api_schema

  OpenApiSpex.schema(%{
    title: "Goal",
    description: "Goal object",
    type: :object,
    discriminator: %OpenApiSpex.Discriminator{
      propertyName: "goal_type",
      mapping: %{
        "Goal.CustomEvent" => Schemas.Goal.CustomEvent,
        "Goal.Pageview" => Schemas.Goal.Pageview,
        "Goal.Revenue" => Schemas.Goal.Revenue
      }
    },
    oneOf: [
      Schemas.Goal.CustomEvent,
      Schemas.Goal.Revenue,
      Schemas.Goal.Pageview
    ],
    example: %{
      goal_type: "Goal.Revenue",
      goal: %{
        currency: "EUR",
        event_name: "Purchase"
      }
    }
  })
end