From 57e6f2757afef8941fe3576dbe5e2014d2569c33 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 4 May 2020 12:47:23 +0200 Subject: [PATCH] ChatOperation: Make simple schema into inline schema --- .../web/api_spec/operations/chat_operation.ex | 18 ++++++++++++++-- .../schemas/chat_message_create_request.ex | 21 ------------------- 2 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 lib/pleroma/web/api_spec/schemas/chat_message_create_request.ex diff --git a/lib/pleroma/web/api_spec/operations/chat_operation.ex b/lib/pleroma/web/api_spec/operations/chat_operation.ex index ad05f5ac7..e8b5eff1f 100644 --- a/lib/pleroma/web/api_spec/operations/chat_operation.ex +++ b/lib/pleroma/web/api_spec/operations/chat_operation.ex @@ -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 @@ def post_chat_message_operation 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 @@ def chat_messages_response 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 index 8e1b7af14..000000000 --- a/lib/pleroma/web/api_spec/schemas/chat_message_create_request.ex +++ /dev/null @@ -1,21 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors -# 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