allow disabling prometheus entirely
[akkoma] / test / pleroma / web / api_spec / schema_examples_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.SchemaExamplesTest do
6 use ExUnit.Case, async: true
7 import Pleroma.Tests.ApiSpecHelpers
8
9 @content_type "application/json"
10
11 for operation <- api_operations() do
12 describe operation.operationId <> " Request Body" do
13 if operation.requestBody do
14 @media_type operation.requestBody.content[@content_type]
15 @schema resolve_schema(@media_type.schema)
16
17 if @media_type.example do
18 test "request body media type example matches schema" do
19 assert_schema(@media_type.example, @schema)
20 end
21 end
22
23 if @schema.example do
24 test "request body schema example matches schema" do
25 assert_schema(@schema.example, @schema)
26 end
27 end
28 end
29 end
30
31 for {status, response} <- operation.responses, is_map(response.content[@content_type]) do
32 describe "#{operation.operationId} - #{status} Response" do
33 @schema resolve_schema(response.content[@content_type].schema)
34
35 if @schema.example do
36 test "example matches schema" do
37 assert_schema(@schema.example, @schema)
38 end
39 end
40 end
41 end
42 end
43 end