swagger-api/swagger-codegen

[Ruby, PHP] Errors with slashes in pattern

Open

#3.703 geöffnet am 1. Sept. 2016

Auf GitHub ansehen
 (8 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)HTML (5.474 Forks)batch import
Client: PHPClient: RubyIssue: Bughelp wanted

Repository-Metriken

Stars
 (12.701 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide