forked from AkkomaGang/akkoma
Fix API spec, add app schema
This commit is contained in:
parent
ba6914f90a
commit
baa8196fc9
2 changed files with 37 additions and 29 deletions
|
@ -6,6 +6,7 @@ defmodule Pleroma.Web.ApiSpec.AppOperation do
|
||||||
alias OpenApiSpex.Operation
|
alias OpenApiSpex.Operation
|
||||||
alias OpenApiSpex.Schema
|
alias OpenApiSpex.Schema
|
||||||
alias Pleroma.Web.ApiSpec.Helpers
|
alias Pleroma.Web.ApiSpec.Helpers
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.App
|
||||||
|
|
||||||
@spec open_api_operation(atom) :: Operation.t()
|
@spec open_api_operation(atom) :: Operation.t()
|
||||||
def open_api_operation(action) do
|
def open_api_operation(action) do
|
||||||
|
@ -21,7 +22,7 @@ def index_operation do
|
||||||
description: "List the OAuth applications for the current user",
|
description: "List the OAuth applications for the current user",
|
||||||
operationId: "AppController.index",
|
operationId: "AppController.index",
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("App", "application/json", index_response())
|
200 => Operation.response("Array of App", "application/json", array_of_apps())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -159,33 +160,7 @@ defp create_response do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp index_response do
|
defp array_of_apps do
|
||||||
%Schema{
|
%Schema{type: :array, items: App, example: [App.schema().example]}
|
||||||
title: "AppIndexResponse",
|
|
||||||
description: "Response schema for GET /api/v1/apps",
|
|
||||||
type: :object,
|
|
||||||
properties: [
|
|
||||||
%{
|
|
||||||
id: %Schema{type: :string},
|
|
||||||
name: %Schema{type: :string},
|
|
||||||
client_id: %Schema{type: :string},
|
|
||||||
client_secret: %Schema{type: :string},
|
|
||||||
redirect_uri: %Schema{type: :string},
|
|
||||||
vapid_key: %Schema{type: :string},
|
|
||||||
website: %Schema{type: :string, nullable: true}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
example: [
|
|
||||||
%{
|
|
||||||
"id" => "123",
|
|
||||||
"name" => "My App",
|
|
||||||
"client_id" => "TWhM-tNSuncnqN7DBJmoyeLnk6K3iJJ71KKXxgL1hPM",
|
|
||||||
"client_secret" => "ZEaFUFmF0umgBX1qKJDjaU99Q31lDkOU8NutzTOoliw",
|
|
||||||
"vapid_key" =>
|
|
||||||
"BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=",
|
|
||||||
"website" => "https://myapp.com/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
33
lib/pleroma/web/api_spec/schemas/app.ex
Normal file
33
lib/pleroma/web/api_spec/schemas/app.ex
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ApiSpec.Schemas.App do
|
||||||
|
alias OpenApiSpex.Schema
|
||||||
|
|
||||||
|
require OpenApiSpex
|
||||||
|
|
||||||
|
OpenApiSpex.schema(%{
|
||||||
|
title: "App",
|
||||||
|
description: "Response schema for an app",
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
id: %Schema{type: :string},
|
||||||
|
name: %Schema{type: :string},
|
||||||
|
client_id: %Schema{type: :string},
|
||||||
|
client_secret: %Schema{type: :string},
|
||||||
|
redirect_uri: %Schema{type: :string},
|
||||||
|
vapid_key: %Schema{type: :string},
|
||||||
|
website: %Schema{type: :string, nullable: true}
|
||||||
|
},
|
||||||
|
example: %{
|
||||||
|
"id" => "123",
|
||||||
|
"name" => "My App",
|
||||||
|
"client_id" => "TWhM-tNSuncnqN7DBJmoyeLnk6K3iJJ71KKXxgL1hPM",
|
||||||
|
"client_secret" => "ZEaFUFmF0umgBX1qKJDjaU99Q31lDkOU8NutzTOoliw",
|
||||||
|
"vapid_key" =>
|
||||||
|
"BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=",
|
||||||
|
"website" => "https://myapp.com/"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
Loading…
Reference in a new issue