First of all: thanks for the hard work on this Hex package. I love it ❤️
It seems there is a small bug when casting an Object mentioned in allOf that contains a property that is an array and mentions another Schema with items.
An example. Given the following schemas:
defmodule Hobby do
require OpenApiSpex
alias OpenApiSpex.Schema
OpenApiSpex.schema(%{
type: :object,
properties: %{
name: %Schema{type: :string, minLength: 1, maxLength: 30}
}
})
end
defmodule Person do
require OpenApiSpex
alias OpenApiSpex.Schema
OpenApiSpex.schema(%{
type: :object,
properties: %{
hobbies: %Schema{type: :array, items: Hobby}
}
})
end
defmodule Employee do
require OpenApiSpex
alias OpenApiSpex.Schema
OpenApiSpex.schema(%{
type: :object,
allOf: [
Person,
%Schema{
type: :object,
properties: %{
employee_number: %Schema{type: :string}
}
}
]
})
end
When using the Person schema, the casting of hobbies works as expected:
However, when using the Employee schema, the casting of hobbies doesn't work as expected (notice that hobbies now contain a list of maps instead of Hobby structs):
So it seems that using allOf doesn't comply to the mentioned items schema. Hope these examples clarify the problem a bit. If you need any help or more information, please let me know! I am happy to help you out.
First of all: thanks for the hard work on this Hex package. I love it ❤️
It seems there is a small bug when casting an
Object
mentioned inallOf
that contains a property that is anarray
and mentions another Schema withitems
.An example. Given the following schemas:
When using the
Person
schema, the casting ofhobbies
works as expected:However, when using the
Employee
schema, the casting ofhobbies
doesn't work as expected (notice thathobbies
now contain a list of maps instead ofHobby
structs):But, if I would change the
Employee
schema to:It works:
So it seems that using
allOf
doesn't comply to the mentioneditems
schema. Hope these examples clarify the problem a bit. If you need any help or more information, please let me know! I am happy to help you out.