1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.SchemaExamplesTest do
6 use ExUnit.Case, async: true
7 import Pleroma.Tests.ApiSpecHelpers
9 @content_type "application/json"
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)
17 if @media_type.example do
18 test "request body media type example matches schema" do
19 assert_schema(@media_type.example, @schema)
24 test "request body schema example matches schema" do
25 assert_schema(@schema.example, @schema)
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)
36 test "example matches schema" do
37 assert_schema(@schema.example, @schema)