Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot add nullable property in schema's example #294

Open
DenysGonchar opened this issue Jun 17, 2024 · 2 comments
Open

cannot add nullable property in schema's example #294

DenysGonchar opened this issue Jun 17, 2024 · 2 comments

Comments

@DenysGonchar
Copy link

DenysGonchar commented Jun 17, 2024

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"
}
@maysam
Copy link

maysam commented Oct 8, 2024

@DenysGonchar use the master branch instead of the old hex version

@maysam
Copy link

maysam commented Oct 8, 2024

#162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants