From b8c68322e6e800e9a54d3eab0ac1fd6a203cb79e Mon Sep 17 00:00:00 2001 From: LETICIA AUGUSTO PENHA <38891800+leticiapenha@users.noreply.github.com> Date: Mon, 30 May 2022 15:47:35 -0300 Subject: [PATCH] Updating test helpers doc --- guides/test-helpers.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guides/test-helpers.md b/guides/test-helpers.md index 4958dadd..7261d3a7 100644 --- a/guides/test-helpers.md +++ b/guides/test-helpers.md @@ -3,6 +3,19 @@ PhoenixSwagger also includes a testing helper module `PhoenixSwagger.SchemaTest` to conveniently assert that responses from Phoenix controller actions conform to your swagger schema. +In order to validate the swagger schema, the properties options must be required true in swagger definitions: + +```elixir + properties do + id(:integer, "User ID") + name(:string, "User name", required: true) + email(:string, "Email address", format: :email, required: true) + inserted_at(:string, "Creation timestamp", format: :datetime) + updated_at(:string, "Update timestamp", format: :datetime) + end +``` + + In your controller test files add the `PhoenixSwagger.SchemaTest` mixin with the path to your swagger spec: ```elixir