Skip to content

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

Open
@robin123123123

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions