Skip to content

[Ruby, PHP] Errors with slashes in pattern #3703

Open
@scop

Description

@scop
Description

For this in YAML syntax:

pattern: '^a/b$'

...the PHP code generated is:

if (!preg_match("/^a/b$/", ...

...and for Ruby:

Regexp.new(/^a/b$/)

The problem with both is that the slash between a and b should be backslash escaped to avoid errors. I tried this in DefaultCodegen.addRegularExpressionDelimiter:

return "/" + pattern.replace("/", "\\/") + "/";

...but it makes no difference on the eventual output.

Swagger-codegen version

Current master

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions