alias OpenApiSpex.Operation
alias OpenApiSpex.Reference
alias OpenApiSpex.Schema
- alias Pleroma.Web.ApiSpec.Helpers
alias Pleroma.Web.ApiSpec.Schemas.Account
alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
+ alias Pleroma.Web.ApiSpec.Schemas.AccountFollowsRequest
alias Pleroma.Web.ApiSpec.Schemas.AccountMuteRequest
alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
alias Pleroma.Web.ApiSpec.Schemas.AccountRelationshipsResponse
alias Pleroma.Web.ApiSpec.Schemas.StatusesResponse
alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
+ import Pleroma.Web.ApiSpec.Helpers
+
@spec open_api_operation(atom) :: Operation.t()
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
description:
"Creates a user and account records. Returns an account access token for the app that initiated the request. The app should save this token for later, and should wait for the user to confirm their account by clicking a link in their email inbox.",
operationId: "AccountController.create",
- requestBody: Helpers.request_body("Parameters", AccountCreateRequest, required: true),
+ requestBody: request_body("Parameters", AccountCreateRequest, required: true),
responses: %{
200 => Operation.response("Account", "application/json", AccountCreateResponse)
}
description: "Update the user's display and preferences.",
operationId: "AccountController.update_credentials",
security: [%{"oAuth" => ["write:accounts"]}],
- requestBody:
- Helpers.request_body("Parameters", AccountUpdateCredentialsRequest, required: true),
+ requestBody: request_body("Parameters", AccountUpdateCredentialsRequest, required: true),
responses: %{
200 => Operation.response("Account", "application/json", Account)
}
operationId: "AccountController.statuses",
description:
"Statuses posted to the given account. Public (for public statuses only), or user token + `read:statuses` (for private statuses the user is authorized to see)",
- parameters: [
- %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
- Operation.parameter(:pinned, :query, BooleanLike, "Pinned"),
- Operation.parameter(:tagged, :query, :string, "With tag"),
- Operation.parameter(:only_media, :query, BooleanLike, "Only meadia"),
- Operation.parameter(:with_muted, :query, BooleanLike, "With muted"),
- Operation.parameter(:exclude_reblogs, :query, BooleanLike, "Exclude reblobs"),
- Operation.parameter(
- :exclude_visibilities,
- :query,
- %Schema{type: :array, items: VisibilityScope},
- "Exclude visibilities"
- ),
- Operation.parameter(:max_id, :query, :string, "Max ID"),
- Operation.parameter(:min_id, :query, :string, "Mix ID"),
- Operation.parameter(:since_id, :query, :string, "Since ID"),
- Operation.parameter(
- :limit,
- :query,
- %Schema{type: :integer, default: 20, maximum: 40},
- "Limit"
- )
- ],
+ parameters:
+ [
+ %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+ Operation.parameter(:pinned, :query, BooleanLike, "Include only pinned statuses"),
+ Operation.parameter(:tagged, :query, :string, "With tag"),
+ Operation.parameter(
+ :only_media,
+ :query,
+ BooleanLike,
+ "Include only statuses with media attached"
+ ),
+ Operation.parameter(
+ :with_muted,
+ :query,
+ BooleanLike,
+ "Include statuses from muted acccounts."
+ ),
+ Operation.parameter(:exclude_reblogs, :query, BooleanLike, "Exclude reblogs"),
+ Operation.parameter(
+ :exclude_visibilities,
+ :query,
+ %Schema{type: :array, items: VisibilityScope},
+ "Exclude visibilities"
+ )
+ ] ++ pagination_params(),
responses: %{
200 => Operation.response("Statuses", "application/json", StatusesResponse)
}
security: [%{"oAuth" => ["read:accounts"]}],
description:
"Accounts which follow the given account, if network is not hidden by the account owner.",
- parameters: [
- %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
- Operation.parameter(:max_id, :query, :string, "Max ID"),
- Operation.parameter(:min_id, :query, :string, "Mix ID"),
- Operation.parameter(:since_id, :query, :string, "Since ID"),
- Operation.parameter(
- :limit,
- :query,
- %Schema{type: :integer, default: 20, maximum: 40},
- "Limit"
- )
- ],
+ parameters:
+ [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}] ++ pagination_params(),
responses: %{
200 => Operation.response("Accounts", "application/json", AccountsResponse)
}
security: [%{"oAuth" => ["read:accounts"]}],
description:
"Accounts which the given account is following, if network is not hidden by the account owner.",
- parameters: [
- %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
- Operation.parameter(:max_id, :query, :string, "Max ID"),
- Operation.parameter(:min_id, :query, :string, "Mix ID"),
- Operation.parameter(:since_id, :query, :string, "Since ID"),
- Operation.parameter(
- :limit,
- :query,
- %Schema{type: :integer, default: 20, maximum: 40},
- "Limit"
- )
- ],
+ parameters:
+ [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}] ++ pagination_params(),
responses: %{200 => Operation.response("Accounts", "application/json", AccountsResponse)}
}
end
summary: "Mute",
operationId: "AccountController.mute",
security: [%{"oAuth" => ["follow", "write:mutes"]}],
- requestBody: Helpers.request_body("Parameters", AccountMuteRequest),
+ requestBody: request_body("Parameters", AccountMuteRequest),
description:
"Mute the given account. Clients should filter statuses and notifications from this account, if received (e.g. due to a boost in the Home timeline).",
parameters: [
}
end
- def follows_operation, do: :ok
- def mutes_operation, do: :ok
- def blocks_operation, do: :ok
- def endorsements_operation, do: :ok
+ def follows_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Follows",
+ operationId: "AccountController.follows",
+ security: [%{"oAuth" => ["follow", "write:follows"]}],
+ requestBody: request_body("Parameters", AccountFollowsRequest, required: true),
+ responses: %{
+ 200 => Operation.response("Account", "application/json", AccountRelationship)
+ }
+ }
+ end
+
+ def mutes_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Muted accounts",
+ operationId: "AccountController.mutes",
+ description: "Accounts the user has muted.",
+ security: [%{"oAuth" => ["follow", "read:mutes"]}],
+ responses: %{
+ 200 => Operation.response("Accounts", "application/json", AccountsResponse)
+ }
+ }
+ end
+
+ def blocks_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Blocked users",
+ operationId: "AccountController.blocks",
+ description: "View your blocks. See also accounts/:id/{block,unblock}",
+ security: [%{"oAuth" => ["read:blocks"]}],
+ responses: %{
+ 200 => Operation.response("Accounts", "application/json", AccountsResponse)
+ }
+ }
+ end
+
+ def endorsements_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Endorsements",
+ operationId: "AccountController.endorsements",
+ description: "Not implemented",
+ security: [%{"oAuth" => ["read:accounts"]}],
+ responses: %{
+ 200 => Operation.response("Empry array", "application/json", %Schema{type: :array})
+ }
+ }
+ end
+
+ def identity_proofs_operation do
+ %Operation{
+ tags: ["accounts"],
+ summary: "Identity proofs",
+ operationId: "AccountController.identity_proofs",
+ description: "Not implemented",
+ responses: %{
+ 200 => Operation.response("Empry array", "application/json", %Schema{type: :array})
+ }
+ }
+ end
end