-
Notifications
You must be signed in to change notification settings - Fork 201
feat: Add OTP 28+ compatibility with version-aware regex pattern handling #670
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
base: master
Are you sure you want to change the base?
feat: Add OTP 28+ compatibility with version-aware regex pattern handling #670
Conversation
…ling - Implement OTP version detection in schema macro - Add runtime schema compilation for OTP 28+ when regex patterns are present - Maintain module attribute optimization for non-regex schemas on all OTP versions - Add deprecation warning for regex patterns on OTP 28+ with migration guidance - Fix cast_parameters.ex to avoid regex in module attributes - Update string test to check pattern source instead of regex struct equality This ensures backward compatibility while providing a clear migration path for OTP 28+ users to move from regex patterns to string patterns.
lib/open_api_spex/schema.ex
Outdated
|> has_regex_pattern?() | ||
end | ||
|
||
def has_regex_pattern?(enumerable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guard is giving a warning CI:
==> open_api_spex
Compiling 80 files (.ex)
warning: incompatible types:
map() !~ [dynamic()]
in expression:
# lib/open_api_spex/schema.ex:544
is_list(enumerable)
where "enumerable" was given the type map() in:
# lib/open_api_spex/schema.ex:544
is_map_key(enumerable, :__struct__)
where "enumerable" was given the type [dynamic()] in:
# lib/open_api_spex/schema.ex:544
is_list(enumerable)
Conflict found at
│
544 │ when not is_struct(enumerable) and (is_list(enumerable) or is_map(enumerable)) do
│ ~
│
└─ lib/open_api_spex/schema.ex:544:43: OpenApiSpex.Schema.has_regex_pattern?/1
Compilation failed due to warnings while using the --warnings-as-errors option
Error: Process completed with exit code 1.
@@ -253,32 +253,59 @@ defmodule OpenApiSpex do | |||
prevent "... protocol has already been consolidated ..." | |||
compiler warnings. | |||
""" | |||
def should_use_runtime_compilation?(body) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be a public function. It's also hijacking the @doc
for defmacro schema/2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll submit a change to fix this, but that method is called from elsewhere, so I think it needs to be public, no? Unless I'm missing something. The @doc issue is easier to fix (I think). :)
- Fix type incompatibility warning in has_regex_pattern?/1 by splitting function clauses - Make should_use_runtime_compilation?/1 undocumented (@doc false) Addresses feedback in open-api-spex#670 (review)
Including:
This ensures backward compatibility while providing a clear migration path for OTP 28+ users to move from regex patterns to string patterns.