projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'issue/1934-welcome-email' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
api_spec
/
operations
/
media_operation.ex
diff --git
a/lib/pleroma/web/api_spec/operations/media_operation.ex
b/lib/pleroma/web/api_spec/operations/media_operation.ex
index 0fe686efa7f4a6ced8f4f269d5bae872bb9b3564..d9c3c42db2fe70790f99860d6a08cc1ffcb9b7e8 100644
(file)
--- a/
lib/pleroma/web/api_spec/operations/media_operation.ex
+++ b/
lib/pleroma/web/api_spec/operations/media_operation.ex
@@
-7,6
+7,7
@@
defmodule Pleroma.Web.ApiSpec.MediaOperation do
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Helpers
alias Pleroma.Web.ApiSpec.Schemas.ApiError
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.Helpers
alias Pleroma.Web.ApiSpec.Schemas.ApiError
+ alias Pleroma.Web.ApiSpec.Schemas.Attachment
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
@@
-22,24
+23,24
@@
defmodule Pleroma.Web.ApiSpec.MediaOperation do
security: [%{"oAuth" => ["write:media"]}],
requestBody: Helpers.request_body("Parameters", create_request()),
responses: %{
security: [%{"oAuth" => ["write:media"]}],
requestBody: Helpers.request_body("Parameters", create_request()),
responses: %{
- 200 =>
- Operation.response("Media", "application/json", Pleroma.Web.ApiSpec.Schemas.Attachment),
+ 200 => Operation.response("Media", "application/json", Attachment),
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
}
end
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
}
end
- defp create_request
()
do
+ defp create_request do
%Schema{
title: "MediaCreateRequest",
description: "POST body for creating an attachment",
type: :object,
%Schema{
title: "MediaCreateRequest",
description: "POST body for creating an attachment",
type: :object,
+ required: [:file],
properties: %{
file: %Schema{
properties: %{
file: %Schema{
- type: :
binary
,
-
description: "The file to be attached, using multipart form data."
,
- required: true
+ type: :
string
,
+
format: :binary
,
+ description: "The file to be attached, using multipart form data."
},
description: %Schema{
type: :string,
},
description: %Schema{
type: :string,
@@
-60,29
+61,26
@@
defmodule Pleroma.Web.ApiSpec.MediaOperation do
description: "Creates an attachment to be used with a new status.",
operationId: "MediaController.update",
security: [%{"oAuth" => ["write:media"]}],
description: "Creates an attachment to be used with a new status.",
operationId: "MediaController.update",
security: [%{"oAuth" => ["write:media"]}],
+ parameters: [id_param()],
requestBody: Helpers.request_body("Parameters", update_request()),
responses: %{
requestBody: Helpers.request_body("Parameters", update_request()),
responses: %{
- 200 =>
-
Operation.response("Media", "application/json", Pleroma.Web.ApiSpec.Schemas.Attachment
),
+ 200 =>
Operation.response("Media", "application/json", Attachment),
+
400 => Operation.response("Media", "application/json", ApiError
),
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
}
end
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
}
end
- defp update_request
()
do
+ defp update_request do
%Schema{
%Schema{
- title: "Media
Cre
ateRequest",
- description: "POST body for
cre
ating an attachment",
+ title: "Media
Upd
ateRequest",
+ description: "POST body for
upd
ating an attachment",
type: :object,
properties: %{
type: :object,
properties: %{
- id: %Schema{
- type: :string,
- description: "The id of the Attachment entity to be updated",
- required: true
- },
file: %Schema{
file: %Schema{
- type: :binary,
+ type: :string,
+ format: :binary,
description: "The file to be attached, using multipart form data."
},
description: %Schema{
description: "The file to be attached, using multipart form data."
},
description: %Schema{
@@
-102,10
+100,10
@@
defmodule Pleroma.Web.ApiSpec.MediaOperation do
tags: ["media"],
summary: "Show Uploaded media attachment",
operationId: "MediaController.show",
tags: ["media"],
summary: "Show Uploaded media attachment",
operationId: "MediaController.show",
+ parameters: [id_param()],
security: [%{"oAuth" => ["read:media"]}],
responses: %{
security: [%{"oAuth" => ["read:media"]}],
responses: %{
- 200 =>
- Operation.response("Media", "application/json", Pleroma.Web.ApiSpec.Schemas.Attachment),
+ 200 => Operation.response("Media", "application/json", Attachment),
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
401 => Operation.response("Media", "application/json", ApiError),
422 => Operation.response("Media", "application/json", ApiError)
}
@@
-121,11
+119,14
@@
defmodule Pleroma.Web.ApiSpec.MediaOperation do
security: [%{"oAuth" => ["write:media"]}],
requestBody: Helpers.request_body("Parameters", create_request()),
responses: %{
security: [%{"oAuth" => ["write:media"]}],
requestBody: Helpers.request_body("Parameters", create_request()),
responses: %{
- 202 =>
- Operation.response("Media", "application/json", Pleroma.Web.ApiSpec.Schemas.Attachment),
+ 202 => Operation.response("Media", "application/json", Attachment),
422 => Operation.response("Media", "application/json", ApiError),
500 => Operation.response("Media", "application/json", ApiError)
}
}
end
422 => Operation.response("Media", "application/json", ApiError),
500 => Operation.response("Media", "application/json", ApiError)
}
}
end
+
+ defp id_param do
+ Operation.parameter(:id, :path, :string, "The ID of the Attachment entity")
+ end
end
end