[#2456] OpenAPI: added `embed_relationships` param definition.
authorIvan Tashkinov <ivantashkinov@gmail.com>
Tue, 12 May 2020 17:55:01 +0000 (20:55 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Tue, 12 May 2020 17:55:01 +0000 (20:55 +0300)
lib/pleroma/web/api_spec/helpers.ex
lib/pleroma/web/api_spec/operations/account_operation.ex
lib/pleroma/web/api_spec/operations/search_operation.ex

index 183df43eea9a03819753219ec33b31edac1b3a25..ee077a3f9e79b103ed2225f8a847bedb4639ca21 100644 (file)
@@ -47,6 +47,15 @@ defmodule Pleroma.Web.ApiSpec.Helpers do
     ]
   end
 
+  def embed_relationships_param do
+    Operation.parameter(
+      :embed_relationships,
+      :query,
+      :boolean,
+      "Embed relationships into accounts (Pleroma extension)"
+    )
+  end
+
   def empty_object_response do
     Operation.response("Empty object", "application/json", %Schema{type: :object, example: %{}})
   end
index 70069d6f9671307ec3f07e44b5a8523dedd3fa26..c2a56b7867543edc0e30fc4ed49776eab85fd265 100644 (file)
@@ -156,7 +156,8 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
       description:
         "Accounts which follow the given account, if network is not hidden by the account owner.",
       parameters:
-        [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}] ++ pagination_params(),
+        [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}] ++
+          pagination_params() ++ [embed_relationships_param()],
       responses: %{
         200 => Operation.response("Accounts", "application/json", array_of_accounts())
       }
@@ -172,7 +173,8 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
       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(),
+        [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}] ++
+          pagination_params() ++ [embed_relationships_param()],
       responses: %{200 => Operation.response("Accounts", "application/json", array_of_accounts())}
     }
   end
index 6ea00a9a86d540c036afb9b5cae54c39bd9ee645..0dd908d7fade1ea66f9f92df6e437093723076a6 100644 (file)
@@ -24,29 +24,30 @@ defmodule Pleroma.Web.ApiSpec.SearchOperation do
       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"
-        )
-      ],
+      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()],
       responses: %{
         200 =>
           Operation.response(
@@ -65,40 +66,42 @@ defmodule Pleroma.Web.ApiSpec.SearchOperation do
       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()
-      ],
+      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()],
       responses: %{
         200 => Operation.response("Results", "application/json", results())
       }