logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

schema_examples_test.exs (1349B)


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