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

:not is not checked #638

Open
lud-wj opened this issue Oct 9, 2024 · 0 comments
Open

:not is not checked #638

lud-wj opened this issue Oct 9, 2024 · 0 comments

Comments

@lud-wj
Copy link

lud-wj commented Oct 9, 2024

Reproductible example:

defmodule MySchema do
  alias OpenApiSpex.Schema
  require OpenApiSpex

  OpenApiSpex.schema(%{
    title: "Object",
    type: :object,
    not: %Schema{type: :object, properties: %{code: %Schema{enum: ["bad_code", type: :string]}}},
    properties: %{code: %Schema{type: :string}}
  })
end

defmodule MySpec do
  alias OpenApiSpex.Components
  alias OpenApiSpex.Info
  alias OpenApiSpex.OpenApi

  def spec do
    %OpenApi{
      servers: [],
      info: %Info{
        title: to_string(Application.spec(:my_app, :description)),
        version: to_string(Application.spec(:my_app, :vsn))
      },
      paths: %{},
      components: %Components{
        schemas: %{"MySchema" => MySchema.schema()}
      }
    }
    |> OpenApiSpex.resolve_schema_modules()
  end
end

OpenApiSpex.TestAssertions.assert_schema(%{"code" => "good_code"}, "MySchema", MySpec.spec()) |> dbg()
OpenApiSpex.TestAssertions.assert_schema(%{"code" => "bad_code"}, "MySchema", MySpec.spec()) |> dbg()

Bot calls at the bottom return the valid data, while the second one should raise because "bad_code" is forbidden.

EDIT: Well, looking at the 3.0 specification, it seems that not is not a supported keyword. What is it supposed to do in OpenApiSpex?

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

1 participant