if property is set to :null or nil in schema's example, it's filtered out by if PhoenixSwagger.to_json/1
here is an example:
Interactive Elixir (1.13.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> use PhoenixSwagger
PhoenixSwagger.JsonApi
iex(2)> swagger_schema do
...(2)> property(:someProperty, [:null, :string], "some nullable property")
...(2)> example(%{someProperty: :null})
...(2)> end
%{
"example" => %{},
"properties" => %{
"someProperty" => %{
"description" => "some nullable property",
"type" => [:null, "string"]
}
},
"type" => "object"
}
iex(3)> swagger_schema do
...(3)> property(:someProperty, [:null, :string], "some nullable property")
...(3)> example(%{someProperty: nil})
...(3)> end
%{
"example" => %{},
"properties" => %{
"someProperty" => %{
"description" => "some nullable property",
"type" => [:null, "string"]
}
},
"type" => "object"
}
iex(4)> swagger_schema do
...(4)> property(:someProperty, [:null, :string], "some nullable property")
...(4)> example(%{someProperty: "some_value"})
...(4)> end
%{
"example" => %{"someProperty" => "some_value"},
"properties" => %{
"someProperty" => %{
"description" => "some nullable property",
"type" => [:null, "string"]
}
},
"type" => "object"
}
if property is set to
:nullornilin schema's example, it's filtered out by ifPhoenixSwagger.to_json/1here is an example: