defmodule Pleroma.Web.ApiSpec.Helpers do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
+ alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
def request_body(description, schema_ref, opts \\ []) do
media_types = ["application/json", "multipart/form-data", "application/x-www-form-urlencoded"]
]
end
- def embed_relationships_param do
- Operation.parameter(
- :embed_relationships,
- :query,
- :boolean,
- "Embed relationships into accounts (Pleroma extension)"
- )
+ def with_relationships_param do
+ Operation.parameter(:with_relationships, :query, BooleanLike, "Include relationships")
end
def empty_object_response do
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"}] ++
- pagination_params() ++ [embed_relationships_param()],
+ parameters: [
+ %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+ with_relationships_param() | pagination_params()
+ ],
responses: %{
200 => Operation.response("Accounts", "application/json", array_of_accounts())
}
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"}] ++
- pagination_params() ++ [embed_relationships_param()],
+ parameters: [
+ %Reference{"$ref": "#/components/parameters/accountIdOrNickname"},
+ with_relationships_param() | pagination_params()
+ ],
responses: %{200 => Operation.response("Accounts", "application/json", array_of_accounts())}
}
end
tags: ["Search"],
summary: "Search for matching accounts by username or display name",
operationId: "SearchController.account_search",
- parameters:
- [
- Operation.parameter(:q, :query, %Schema{type: :string}, "What to search for",
- required: true
- ),
- Operation.parameter(
- :limit,
- :query,
- %Schema{type: :integer, default: 40},
- "Maximum number of results"
- ),
- Operation.parameter(
- :resolve,
- :query,
- %Schema{allOf: [BooleanLike], default: false},
- "Attempt WebFinger lookup. Use this when `q` is an exact address."
- ),
- Operation.parameter(
- :following,
- :query,
- %Schema{allOf: [BooleanLike], default: false},
- "Only include accounts that the user is following"
- )
- ] ++ [embed_relationships_param()],
+ parameters: [
+ Operation.parameter(:q, :query, %Schema{type: :string}, "What to search for",
+ required: true
+ ),
+ Operation.parameter(
+ :limit,
+ :query,
+ %Schema{type: :integer, default: 40},
+ "Maximum number of results"
+ ),
+ Operation.parameter(
+ :resolve,
+ :query,
+ %Schema{allOf: [BooleanLike], default: false},
+ "Attempt WebFinger lookup. Use this when `q` is an exact address."
+ ),
+ Operation.parameter(
+ :following,
+ :query,
+ %Schema{allOf: [BooleanLike], default: false},
+ "Only include accounts that the user is following"
+ ),
+ with_relationships_param()
+ ],
responses: %{
200 =>
Operation.response(
security: [%{"oAuth" => ["read:search"]}],
operationId: "SearchController.search",
deprecated: true,
- parameters:
- [
- Operation.parameter(
- :account_id,
- :query,
- FlakeID,
- "If provided, statuses returned will be authored only by this account"
- ),
- Operation.parameter(
- :type,
- :query,
- %Schema{type: :string, enum: ["accounts", "hashtags", "statuses"]},
- "Search type"
- ),
- Operation.parameter(:q, :query, %Schema{type: :string}, "The search query",
- required: true
- ),
- Operation.parameter(
- :resolve,
- :query,
- %Schema{allOf: [BooleanLike], default: false},
- "Attempt WebFinger lookup"
- ),
- Operation.parameter(
- :following,
- :query,
- %Schema{allOf: [BooleanLike], default: false},
- "Only include accounts that the user is following"
- ),
- Operation.parameter(
- :offset,
- :query,
- %Schema{type: :integer},
- "Offset"
- )
- ] ++ pagination_params() ++ [embed_relationships_param()],
+ parameters: [
+ Operation.parameter(
+ :account_id,
+ :query,
+ FlakeID,
+ "If provided, statuses returned will be authored only by this account"
+ ),
+ Operation.parameter(
+ :type,
+ :query,
+ %Schema{type: :string, enum: ["accounts", "hashtags", "statuses"]},
+ "Search type"
+ ),
+ Operation.parameter(:q, :query, %Schema{type: :string}, "The search query", required: true),
+ Operation.parameter(
+ :resolve,
+ :query,
+ %Schema{allOf: [BooleanLike], default: false},
+ "Attempt WebFinger lookup"
+ ),
+ Operation.parameter(
+ :following,
+ :query,
+ %Schema{allOf: [BooleanLike], default: false},
+ "Only include accounts that the user is following"
+ ),
+ Operation.parameter(
+ :offset,
+ :query,
+ %Schema{type: :integer},
+ "Offset"
+ ),
+ with_relationships_param() | pagination_params()
+ ],
responses: %{
200 => Operation.response("Results", "application/json", results())
}