aa3b69a1867c1cb877538c860609b3068d18eeb6
[akkoma] / lib / pleroma / web / api_spec / operations / translate_operation.ex
1 defmodule Pleroma.Web.ApiSpec.TranslationOperation do
2 alias OpenApiSpex.Operation
3 alias OpenApiSpex.Schema
4
5 @spec open_api_operation(atom) :: Operation.t()
6 def open_api_operation(action) do
7 operation = String.to_existing_atom("#{action}_operation")
8 apply(__MODULE__, operation, [])
9 end
10
11 @spec languages_operation() :: Operation.t()
12 def languages_operation() do
13 %Operation{
14 tags: ["Retrieve status translation"],
15 summary: "Translate status",
16 description: "View the translation of a given status",
17 operationId: "AkkomaAPI.TranslationController.languages",
18 security: [%{"oAuth" => ["read:statuses"]}],
19 responses: %{
20 200 => Operation.response("Translation", "application/json", languages_schema())
21 }
22 }
23 end
24
25 defp languages_schema do
26 %Schema{
27 type: "array",
28 items: %Schema{
29 type: "object",
30 properties: %{
31 code: %Schema{
32 type: "string"
33 },
34 name: %Schema{
35 type: "string"
36 }
37 }
38 }
39 }
40 end
41 end