mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
0007c0c108
* Remove "Context" namespace level * Change Goal string representation * Alias Schemas in Plugin API Test Case template * Update schema & tests for SharedLink resource * Update Goals interface - make it possible to create revenue goals - extract "for site" query to a standalone function * Fixup typespecs * Alias Errors module in OpenAPI controllers * Add missing goals test * Implement Goals Plugins API resource * Add extra test to confirm changeset error propagation * Mute credo * Fix typos * Handle changeset traversal in `Errors` * Use upserts in `Goals.find_or_create` * Extract touch_site! to Site.Cache, address credo, improve code docs * Apply formatting * Remove unused inner join * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update error message on revenue goal currency clash * Remove unused code --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
33 lines
749 B
Elixir
33 lines
749 B
Elixir
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
|