diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-04-15 16:45:45 +0400 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-04-15 16:45:45 +0400 |
commit | 0e647ff55aa3128f45cd9df79b8af06da57c009e (patch) | |
tree | 2c1a687746585cd0ffda7c8d81664b54693ec04c /lib/pleroma/web/api_spec/helpers.ex | |
parent | 8ed162b65538ee3cb5b125587fd65657b36ca143 (diff) | |
download | pleroma-0e647ff55aa3128f45cd9df79b8af06da57c009e.tar.gz |
Abstract pagination params in OpenAPI spec
Diffstat (limited to 'lib/pleroma/web/api_spec/helpers.ex')
-rw-r--r-- | lib/pleroma/web/api_spec/helpers.ex | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/helpers.ex b/lib/pleroma/web/api_spec/helpers.ex index 7348dcbee..ce40fb9e8 100644 --- a/lib/pleroma/web/api_spec/helpers.ex +++ b/lib/pleroma/web/api_spec/helpers.ex @@ -3,6 +3,9 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ApiSpec.Helpers do + alias OpenApiSpex.Operation + alias OpenApiSpex.Schema + def request_body(description, schema_ref, opts \\ []) do media_types = ["application/json", "multipart/form-data", "application/x-www-form-urlencoded"] @@ -24,4 +27,23 @@ defmodule Pleroma.Web.ApiSpec.Helpers do required: opts[:required] || false } end + + def pagination_params do + [ + Operation.parameter(:max_id, :query, :string, "Return items older than this ID"), + Operation.parameter(:min_id, :query, :string, "Return the oldest items newer than this ID"), + Operation.parameter( + :since_id, + :query, + :string, + "Return the newest items newer than this ID" + ), + Operation.parameter( + :limit, + :query, + %Schema{type: :integer, default: 20, maximum: 40}, + "Limit" + ) + ] + end end |