-
I'm making a test for my schema response and the Example 1:
also does this (the real test): Example 2:
Only don't pass if I use something different of a map in the assert_schema arguments: Example 3:
My question and the whole problem is: why does Example 1 pass the assert? It should only pass if the result is exactly equal to the schema (like Example 2). My "Event" schema looks like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It might be because your schema doesn't have any required properties. So any map is actually a valid data for the schema. %OpenApiSpex.Schema%{
example: %{
id: "d36bcaf0-f0a0-4ad1-a038-e7d3ba951b17",
json_data: nil,
str_type: "Event example",
ts_created_at: "2022-03-01T17:00:25.442265Z"
},
properties: %{
id: %OpenApiSpex.Reference{"$ref": "#/components/schemas/UUID"},
json_data: %OpenApiSpex.Schema%{description: "Event data", type: :object},
str_type: %OpenApiSpex.Schema%{
description: "Event type",
maxLength: 64,
type: :string
},
ts_created_at: %OpenApiSpex.Schema%{
description: "Date-time when the Event was created",
format: "date-time",
type: :string
}
},
required: [:id, :json_data, :str_type, :ts_created_at],
title: "Event",
type: :object,
"x-struct": MyApp.Swagger.Schemas.Event
} |
Beta Was this translation helpful? Give feedback.
-
oh god, can't believe it's just it... it works, I also needed to use the |
Beta Was this translation helpful? Give feedback.
It might be because your schema doesn't have any required properties. So any map is actually a valid data for the schema.
What happens if you change your schema to the following?