X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fweb%2Fapi_spec%2Foperations%2Ffilter_operation.ex;h=ac0444aef46d1d305873e0a0ebca74774836574d;hb=a079ec3a3cdfd42d2cbd51c7698c2c87828e5778;hp=53e57b46bc6ce04919aa7efb252d248c625d1b1c;hpb=e18958a5d7ed2d31026ee921dfcc0501b5d2881b;p=akkoma
diff --git a/lib/pleroma/web/api_spec/operations/filter_operation.ex b/lib/pleroma/web/api_spec/operations/filter_operation.ex
index 53e57b46b..ac0444aef 100644
--- a/lib/pleroma/web/api_spec/operations/filter_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/filter_operation.ex
@@ -1,11 +1,13 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.FilterOperation do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Helpers
+ alias Pleroma.Web.ApiSpec.Schemas.ApiError
+ alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
@@ -14,57 +16,64 @@ defmodule Pleroma.Web.ApiSpec.FilterOperation do
def index_operation do
%Operation{
- tags: ["apps"],
- summary: "View all filters",
+ tags: ["Filters"],
+ summary: "All filters",
operationId: "FilterController.index",
security: [%{"oAuth" => ["read:filters"]}],
responses: %{
- 200 => Operation.response("Filters", "application/json", array_of_filters())
+ 200 => Operation.response("Filters", "application/json", array_of_filters()),
+ 403 => Operation.response("Error", "application/json", ApiError)
}
}
end
def create_operation do
%Operation{
- tags: ["apps"],
+ tags: ["Filters"],
summary: "Create a filter",
operationId: "FilterController.create",
requestBody: Helpers.request_body("Parameters", create_request(), required: true),
security: [%{"oAuth" => ["write:filters"]}],
- responses: %{200 => Operation.response("Filter", "application/json", filter())}
+ responses: %{
+ 200 => Operation.response("Filter", "application/json", filter()),
+ 403 => Operation.response("Error", "application/json", ApiError)
+ }
}
end
def show_operation do
%Operation{
- tags: ["apps"],
- summary: "View all filters",
+ tags: ["Filters"],
+ summary: "Filter",
parameters: [id_param()],
operationId: "FilterController.show",
security: [%{"oAuth" => ["read:filters"]}],
responses: %{
- 200 => Operation.response("Filter", "application/json", filter())
+ 200 => Operation.response("Filter", "application/json", filter()),
+ 403 => Operation.response("Error", "application/json", ApiError),
+ 404 => Operation.response("Error", "application/json", ApiError)
}
}
end
def update_operation do
%Operation{
- tags: ["apps"],
+ tags: ["Filters"],
summary: "Update a filter",
parameters: [id_param()],
operationId: "FilterController.update",
requestBody: Helpers.request_body("Parameters", update_request(), required: true),
security: [%{"oAuth" => ["write:filters"]}],
responses: %{
- 200 => Operation.response("Filter", "application/json", filter())
+ 200 => Operation.response("Filter", "application/json", filter()),
+ 403 => Operation.response("Error", "application/json", ApiError)
}
}
end
def delete_operation do
%Operation{
- tags: ["apps"],
+ tags: ["Filters"],
summary: "Remove a filter",
parameters: [id_param()],
operationId: "FilterController.delete",
@@ -74,7 +83,8 @@ defmodule Pleroma.Web.ApiSpec.FilterOperation do
Operation.response("Filter", "application/json", %Schema{
type: :object,
description: "Empty object"
- })
+ }),
+ 403 => Operation.response("Error", "application/json", ApiError)
}
}
end
@@ -171,7 +181,7 @@ defmodule Pleroma.Web.ApiSpec.FilterOperation do
type: :object,
properties: %{
irreversible: %Schema{
- type: :bolean,
+ allOf: [BooleanLike],
description:
"Should the server irreversibly drop matching entities from home and notifications?",
default: false
@@ -199,23 +209,29 @@ defmodule Pleroma.Web.ApiSpec.FilterOperation do
"Array of enumerable strings `home`, `notifications`, `public`, `thread`. At least one context must be specified."
},
irreversible: %Schema{
- type: :bolean,
+ allOf: [BooleanLike],
+ nullable: true,
description:
"Should the server irreversibly drop matching entities from home and notifications?"
},
whole_word: %Schema{
- type: :bolean,
+ allOf: [BooleanLike],
+ nullable: true,
description: "Consider word boundaries?",
default: true
+ },
+ expires_in: %Schema{
+ nullable: true,
+ type: :integer,
+ description:
+ "Number of seconds from now the filter should expire. Otherwise, null for a filter that doesn't expire."
+ },
+ expires_at: %Schema{
+ nullable: true,
+ type: :string,
+ description:
+ "When the filter should no longer be applied. String (ISO 8601 Datetime), or null if the filter does not expire."
}
- # TODO: probably should implement filter expiration
- # expires_in: %Schema{
- # type: :string,
- # format: :"date-time",
- # description:
- # "ISO 8601 Datetime for when the filter expires. Otherwise,
- # null for a filter that doesn't expire."
- # }
},
required: [:phrase, :context],
example: %{