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

[Bug] x-validate module type error when YAML schema: should be an atom #646

Closed
GPrimola opened this issue Dec 16, 2024 · 1 comment
Closed

Comments

@GPrimola
Copy link
Contributor

Hi,

I'm trying to use custom validators for specific types that require fine validations that OpenAPI doesn't support.
I came across the option x-validate, but when I try to use it I get a type error.
I'm defining my schemas in a YAML file and I think this option was designed with the module-based schema definition only.

10:45:27.528 [error] ** (ArgumentError) you attempted to apply a function on "MyApp.Spex.Validations.Regex". Modules (the first argument of apply) must always be an atom
    (erts 15.1) :erlang.apply("MyApp.Spex.Validations.Regex", :cast, [%OpenApiSpex.Cast{value: "*", schema: %OpenApiSpex.Schema%{type: :string, description: "If the format is regex, this option must be set specifying the Ruby Regular Expression to be used to parse and compose the structured message.", title: "Regex", "x-validate": "MyApp.Spex.Validations.Regex"}

schema:

...
regex:
  title: Regex
  description: this must be set specifying the Ruby Regular Expression to be used to parse.
  type: string
  x-validate: MyApp.Spex.Validations.Regex
...

Issue found at: https://github.com/open-api-spex/open_api_spex/blob/v3.21.2/lib/open_api_spex/cast.ex#L122

@GPrimola
Copy link
Contributor Author

GPrimola commented Dec 17, 2024

Fixed in #647

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