ChatOperation: Make simple schema into inline schema

This commit is contained in:
lain 2020-05-04 12:47:23 +02:00
parent dcf535fe77
commit 57e6f2757a
2 changed files with 16 additions and 23 deletions

View 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 @@ 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

View File

@ -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