logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

pleroma_settings_operation.ex (2077B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ApiSpec.PleromaSettingsOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. import Pleroma.Web.ApiSpec.Helpers
  8. def open_api_operation(action) do
  9. operation = String.to_existing_atom("#{action}_operation")
  10. apply(__MODULE__, operation, [])
  11. end
  12. def show_operation do
  13. %Operation{
  14. tags: ["Settings"],
  15. summary: "Get settings for an application",
  16. description: "Get synchronized settings for an application",
  17. operationId: "SettingsController.show",
  18. parameters: [app_name_param()],
  19. security: [%{"oAuth" => ["read:accounts"]}],
  20. responses: %{
  21. 200 => Operation.response("object", "application/json", object())
  22. }
  23. }
  24. end
  25. def update_operation do
  26. %Operation{
  27. tags: ["Settings"],
  28. summary: "Update settings for an application",
  29. description: "Update synchronized settings for an application",
  30. operationId: "SettingsController.update",
  31. parameters: [app_name_param()],
  32. security: [%{"oAuth" => ["write:accounts"]}],
  33. requestBody: request_body("Parameters", update_request(), required: true),
  34. responses: %{
  35. 200 => Operation.response("object", "application/json", object())
  36. }
  37. }
  38. end
  39. def app_name_param do
  40. Operation.parameter(:app, :path, %Schema{type: :string}, "Application name",
  41. example: "pleroma-fe",
  42. required: true
  43. )
  44. end
  45. def object do
  46. %Schema{
  47. title: "Settings object",
  48. description: "The object that contains settings for the application.",
  49. type: :object
  50. }
  51. end
  52. def update_request do
  53. %Schema{
  54. title: "SettingsUpdateRequest",
  55. type: :object,
  56. description:
  57. "The settings object to be merged with the current settings. To remove a field, set it to null.",
  58. example: %{
  59. "config1" => true,
  60. "config2_to_unset" => nil
  61. }
  62. }
  63. end
  64. end