Merge branch 'fix/openapi-errors' into 'develop'
OpenAPI: fix various errors pointed out by editor.swagger.io See merge request pleroma/pleroma!3011
This commit is contained in:
commit
402acce525
|
@ -13,10 +13,15 @@ defmodule Pleroma.Web.ApiSpec do
|
||||||
@impl OpenApi
|
@impl OpenApi
|
||||||
def spec do
|
def spec do
|
||||||
%OpenApi{
|
%OpenApi{
|
||||||
servers: [
|
servers:
|
||||||
# Populate the Server info from a phoenix endpoint
|
if Phoenix.Endpoint.server?(:pleroma, Endpoint) do
|
||||||
OpenApiSpex.Server.from_endpoint(Endpoint)
|
[
|
||||||
],
|
# Populate the Server info from a phoenix endpoint
|
||||||
|
OpenApiSpex.Server.from_endpoint(Endpoint)
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end,
|
||||||
info: %OpenApiSpex.Info{
|
info: %OpenApiSpex.Info{
|
||||||
title: "Pleroma",
|
title: "Pleroma",
|
||||||
description: Application.spec(:pleroma, :description) |> to_string(),
|
description: Application.spec(:pleroma, :description) |> to_string(),
|
||||||
|
|
|
@ -72,7 +72,11 @@ def empty_object_response do
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty_array_response do
|
def empty_array_response do
|
||||||
Operation.response("Empty array", "application/json", %Schema{type: :array, example: []})
|
Operation.response("Empty array", "application/json", %Schema{
|
||||||
|
type: :array,
|
||||||
|
items: %Schema{type: :object, example: %{}},
|
||||||
|
example: []
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_content_response do
|
def no_content_response do
|
||||||
|
|
|
@ -372,6 +372,10 @@ def identity_proofs_operation do
|
||||||
tags: ["accounts"],
|
tags: ["accounts"],
|
||||||
summary: "Identity proofs",
|
summary: "Identity proofs",
|
||||||
operationId: "AccountController.identity_proofs",
|
operationId: "AccountController.identity_proofs",
|
||||||
|
# Validators complains about unused path params otherwise
|
||||||
|
parameters: [
|
||||||
|
%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}
|
||||||
|
],
|
||||||
description: "Not implemented",
|
description: "Not implemented",
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => empty_array_response()
|
200 => empty_array_response()
|
||||||
|
@ -469,7 +473,6 @@ defp create_response do
|
||||||
identifier: %Schema{type: :string},
|
identifier: %Schema{type: :string},
|
||||||
message: %Schema{type: :string}
|
message: %Schema{type: :string}
|
||||||
},
|
},
|
||||||
required: [],
|
|
||||||
# Note: example of successful registration with failed login response:
|
# Note: example of successful registration with failed login response:
|
||||||
# example: %{
|
# example: %{
|
||||||
# "identifier" => "missing_confirmed_email",
|
# "identifier" => "missing_confirmed_email",
|
||||||
|
@ -530,7 +533,7 @@ defp update_credentials_request do
|
||||||
nullable: true,
|
nullable: true,
|
||||||
oneOf: [
|
oneOf: [
|
||||||
%Schema{type: :array, items: attribute_field()},
|
%Schema{type: :array, items: attribute_field()},
|
||||||
%Schema{type: :object, additionalProperties: %Schema{type: attribute_field()}}
|
%Schema{type: :object, additionalProperties: attribute_field()}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
# NOTE: `source` field is not supported
|
# NOTE: `source` field is not supported
|
||||||
|
|
|
@ -69,7 +69,7 @@ defp custom_emoji do
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
category: %Schema{type: :string},
|
category: %Schema{type: :string},
|
||||||
tags: %Schema{type: :array}
|
tags: %Schema{type: :array, items: %Schema{type: :string}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -23,7 +23,7 @@ def index_operation do
|
||||||
parameters: [
|
parameters: [
|
||||||
Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
|
Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
|
||||||
Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji",
|
Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji",
|
||||||
required: false
|
required: nil
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
security: [%{"oAuth" => ["read:statuses"]}],
|
security: [%{"oAuth" => ["read:statuses"]}],
|
||||||
|
|
|
@ -187,8 +187,7 @@ defp add_remove_accounts_request(required) when is_boolean(required) do
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
account_ids: %Schema{type: :array, description: "Array of account IDs", items: FlakeID}
|
account_ids: %Schema{type: :array, description: "Array of account IDs", items: FlakeID}
|
||||||
},
|
}
|
||||||
required: required && [:account_ids]
|
|
||||||
},
|
},
|
||||||
required: required
|
required: required
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do
|
defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do
|
||||||
alias OpenApiSpex.Schema
|
alias OpenApiSpex.Schema
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.Emoji
|
||||||
|
|
||||||
require OpenApiSpex
|
require OpenApiSpex
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do
|
||||||
chat_id: %Schema{type: :string},
|
chat_id: %Schema{type: :string},
|
||||||
content: %Schema{type: :string, nullable: true},
|
content: %Schema{type: :string, nullable: true},
|
||||||
created_at: %Schema{type: :string, format: :"date-time"},
|
created_at: %Schema{type: :string, format: :"date-time"},
|
||||||
emojis: %Schema{type: :array},
|
emojis: %Schema{type: :array, items: Emoji},
|
||||||
attachment: %Schema{type: :object, nullable: true},
|
attachment: %Schema{type: :object, nullable: true},
|
||||||
card: %Schema{
|
card: %Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
|
|
|
@ -27,9 +27,9 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ScheduledStatus do
|
||||||
media_ids: %Schema{type: :array, nullable: true, items: %Schema{type: :string}},
|
media_ids: %Schema{type: :array, nullable: true, items: %Schema{type: :string}},
|
||||||
sensitive: %Schema{type: :boolean, nullable: true},
|
sensitive: %Schema{type: :boolean, nullable: true},
|
||||||
spoiler_text: %Schema{type: :string, nullable: true},
|
spoiler_text: %Schema{type: :string, nullable: true},
|
||||||
visibility: %Schema{type: VisibilityScope, nullable: true},
|
visibility: %Schema{allOf: [VisibilityScope], nullable: true},
|
||||||
scheduled_at: %Schema{type: :string, format: :"date-time", nullable: true},
|
scheduled_at: %Schema{type: :string, format: :"date-time", nullable: true},
|
||||||
poll: %Schema{type: Poll, nullable: true},
|
poll: %Schema{allOf: [Poll], nullable: true},
|
||||||
in_reply_to_id: %Schema{type: :string, nullable: true}
|
in_reply_to_id: %Schema{type: :string, nullable: true}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue