1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.MarkerOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Helpers
10 def open_api_operation(action) do
11 operation = String.to_existing_atom("#{action}_operation")
12 apply(__MODULE__, operation, [])
15 def index_operation do
18 summary: "Get saved timeline position",
19 security: [%{"oAuth" => ["read:statuses"]}],
20 operationId: "MarkerController.index",
27 items: %Schema{type: :string, enum: ["home", "notifications"]}
29 "Array of markers to fetch. If not provided, an empty object will be returned."
33 200 => Operation.response("Marker", "application/json", response()),
34 403 => Operation.response("Error", "application/json", api_error())
39 def upsert_operation do
42 summary: "Save position in timeline",
43 operationId: "MarkerController.upsert",
44 requestBody: Helpers.request_body("Parameters", upsert_request(), required: true),
45 security: [%{"oAuth" => ["follow", "write:blocks"]}],
47 200 => Operation.response("Marker", "application/json", response()),
48 403 => Operation.response("Error", "application/json", api_error())
56 description: "Schema for a marker",
59 last_read_id: %Schema{type: :string},
60 version: %Schema{type: :integer},
61 updated_at: %Schema{type: :string},
65 unread_count: %Schema{type: :integer}
70 "last_read_id" => "35098814",
72 "updated_at" => "2019-11-26T22:37:25.239Z",
73 "pleroma" => %{"unread_count" => 5}
80 title: "MarkersResponse",
81 description: "Response schema for markers",
84 notifications: %Schema{allOf: [marker()], nullable: true},
85 home: %Schema{allOf: [marker()], nullable: true}
87 items: %Schema{type: :string},
90 "last_read_id" => "35098814",
92 "updated_at" => "2019-11-26T22:37:25.239Z",
93 "pleroma" => %{"unread_count" => 0}
96 "last_read_id" => "103206604258487607",
98 "updated_at" => "2019-11-26T22:37:25.235Z",
99 "pleroma" => %{"unread_count" => 10}
105 defp upsert_request do
107 title: "MarkersUpsertRequest",
108 description: "Request schema for marker upsert",
111 notifications: %Schema{
115 last_read_id: %Schema{nullable: true, type: :string}
122 last_read_id: %Schema{nullable: true, type: :string}
128 "last_read_id" => "103194548672408537",
130 "updated_at" => "2019-11-24T19:39:39.337Z"
139 properties: %{error: %Schema{type: :string}}