ChatOperation: Make simple schema into inline schema
authorlain <lain@soykaf.club>
Mon, 4 May 2020 10:47:23 +0000 (12:47 +0200)
committerlain <lain@soykaf.club>
Mon, 4 May 2020 10:47:23 +0000 (12:47 +0200)
lib/pleroma/web/api_spec/operations/chat_operation.ex
lib/pleroma/web/api_spec/schemas/chat_message_create_request.ex [deleted file]

index ad05f5ac72ce1fbbba1be1f6e8ea582384f5b8d7..e8b5eff1f170f98853f1e3ef57d83ef811d4cf8c 100644 (file)
@@ -7,7 +7,6 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
   alias OpenApiSpex.Schema
   alias Pleroma.Web.ApiSpec.Schemas.Chat
   alias Pleroma.Web.ApiSpec.Schemas.ChatMessage
-  alias Pleroma.Web.ApiSpec.Schemas.ChatMessageCreateRequest
 
   import Pleroma.Web.ApiSpec.Helpers
 
@@ -97,7 +96,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
       parameters: [
         Operation.parameter(:id, :path, :string, "The ID of the Chat")
       ],
-      requestBody: request_body("Parameters", ChatMessageCreateRequest, required: true),
+      requestBody: request_body("Parameters", chat_message_create(), required: true),
       responses: %{
         200 =>
           Operation.response(
@@ -208,4 +207,19 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
       ]
     }
   end
+
+  def chat_message_create do
+    %Schema{
+      title: "ChatMessageCreateRequest",
+      description: "POST body for creating an chat message",
+      type: :object,
+      properties: %{
+        content: %Schema{type: :string, description: "The content of your message"}
+      },
+      required: [:content],
+      example: %{
+        "content" => "Hey wanna buy feet pics?"
+      }
+    }
+  end
 end
diff --git a/lib/pleroma/web/api_spec/schemas/chat_message_create_request.ex b/lib/pleroma/web/api_spec/schemas/chat_message_create_request.ex
deleted file mode 100644 (file)
index 8e1b7af..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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.Schemas.ChatMessageCreateRequest do
-  alias OpenApiSpex.Schema
-  require OpenApiSpex
-
-  OpenApiSpex.schema(%{
-    title: "ChatMessageCreateRequest",
-    description: "POST body for creating an chat message",
-    type: :object,
-    properties: %{
-      content: %Schema{type: :string, description: "The content of your message"}
-    },
-    required: [:content],
-    example: %{
-      "content" => "Hey wanna buy feet pics?"
-    }
-  })
-end