swagger-api/swagger-codegen

[Ruby, PHP] Errors with slashes in pattern

Open

#3.703 aberto em 1 de set. de 2016

Ver no GitHub
 (8 comments) (2 reactions) (0 assignees)HTML (5.474 forks)batch import
Client: PHPClient: RubyIssue: Bughelp wanted

Métricas do repositório

Stars
 (12.701 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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

Guia do colaborador