2022-08-30 08:58:54 -06:00
|
|
|
defmodule Pleroma.Web.ApiSpec.TranslationOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
|
|
|
|
|
|
|
@spec open_api_operation(atom) :: Operation.t()
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
@spec languages_operation() :: Operation.t()
|
|
|
|
def languages_operation() do
|
|
|
|
%Operation{
|
|
|
|
tags: ["Retrieve status translation"],
|
|
|
|
summary: "Translate status",
|
|
|
|
description: "View the translation of a given status",
|
|
|
|
operationId: "AkkomaAPI.TranslationController.languages",
|
|
|
|
security: [%{"oAuth" => ["read:statuses"]}],
|
|
|
|
responses: %{
|
2022-08-30 10:59:33 -06:00
|
|
|
200 =>
|
|
|
|
Operation.response("Translation", "application/json", source_dest_languages_schema())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp source_dest_languages_schema do
|
|
|
|
%Schema{
|
|
|
|
type: :object,
|
|
|
|
required: [:source, :target],
|
|
|
|
properties: %{
|
|
|
|
source: languages_schema(),
|
|
|
|
target: languages_schema()
|
2022-08-30 08:58:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp languages_schema do
|
|
|
|
%Schema{
|
2022-08-30 10:59:33 -06:00
|
|
|
type: :array,
|
2022-08-30 08:58:54 -06:00
|
|
|
items: %Schema{
|
2022-08-30 10:59:33 -06:00
|
|
|
type: :object,
|
2022-08-30 08:58:54 -06:00
|
|
|
properties: %{
|
|
|
|
code: %Schema{
|
2022-08-30 10:59:33 -06:00
|
|
|
type: :string
|
2022-08-30 08:58:54 -06:00
|
|
|
},
|
|
|
|
name: %Schema{
|
2022-08-30 10:59:33 -06:00
|
|
|
type: :string
|
2022-08-30 08:58:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|