Skip to content

assert_schema passing with any map #435

Answered by mbuhot
LuizFerK asked this question in Q&A
Discussion options

You must be logged in to vote

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?

%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%{
      d…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by LuizFerK
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #434 on March 18, 2022 00:16.