aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/api_spec/helpers.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-04-17 16:23:58 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-04-17 16:23:58 +0300
commit6e6f95c6aed77cbde1a58edcdbb5cc4f68416bca (patch)
tree923a489a9a6144bd31ff54d24140c1fd1259ae05 /lib/pleroma/web/api_spec/helpers.ex
parentac672a9d6bfdd3cba7692f80a883bd38b0b09a57 (diff)
parent09bd1d12c112fe45563c25a76afde65a3381aa26 (diff)
downloadpleroma-6e6f95c6aed77cbde1a58edcdbb5cc4f68416bca.tar.gz
Merge remote-tracking branch 'remotes/origin/develop' into 1559-follow-request-notifications
# Conflicts: # CHANGELOG.md
Diffstat (limited to 'lib/pleroma/web/api_spec/helpers.ex')
-rw-r--r--lib/pleroma/web/api_spec/helpers.ex27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/helpers.ex b/lib/pleroma/web/api_spec/helpers.ex
new file mode 100644
index 000000000..7348dcbee
--- /dev/null
+++ b/lib/pleroma/web/api_spec/helpers.ex
@@ -0,0 +1,27 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ApiSpec.Helpers do
+ def request_body(description, schema_ref, opts \\ []) do
+ media_types = ["application/json", "multipart/form-data", "application/x-www-form-urlencoded"]
+
+ content =
+ media_types
+ |> Enum.map(fn type ->
+ {type,
+ %OpenApiSpex.MediaType{
+ schema: schema_ref,
+ example: opts[:example],
+ examples: opts[:examples]
+ }}
+ end)
+ |> Enum.into(%{})
+
+ %OpenApiSpex.RequestBody{
+ description: description,
+ content: content,
+ required: opts[:required] || false
+ }
+ end
+end