Merge branch 'fix/1658-invite-send' into 'develop'
[akkoma] / lib / pleroma / web / api_spec / helpers.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.Helpers do
6 def request_body(description, schema_ref, opts \\ []) do
7 media_types = ["application/json", "multipart/form-data"]
8
9 content =
10 media_types
11 |> Enum.map(fn type ->
12 {type,
13 %OpenApiSpex.MediaType{
14 schema: schema_ref,
15 example: opts[:example],
16 examples: opts[:examples]
17 }}
18 end)
19 |> Enum.into(%{})
20
21 %OpenApiSpex.RequestBody{
22 description: description,
23 content: content,
24 required: opts[:required] || false
25 }
26 end
27 end