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

Extra generated regex pattern delimiters ('/') generates code that does not work for kotlin #1288

Open
robin123123123 opened this issue May 23, 2024 · 0 comments · May be fixed by #1289
Open

Comments

@robin123123123
Copy link

robin123123123 commented May 23, 2024

DESCRIPTION
It has been noted before, 10827 8124 that in some languages and frameworks it is not desirable to automatically include regular expression delimiters in a pattern.

I'm using some custom mustache files based on openapi-generator to generate classes for a kotlin-spring application : beanValidationCore.mustache

This now generates jakarta validation annotations like this:

@Pattern(regexp="/^[0-9a-zA-Z]{0,5}$/")

This does not work, as it's now matching the forward slash '/'.

PROPOSED SOLUTION
My suggestion is to override toRegularExpression in the AbstractKotlinCodegen similar to what has been done in AbstractJavaCodegen, so that it does not create extra regular expression delimiters.
It's easier to add this in a mustache/handlebar files, than to remove it.

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