swagger-api/swagger-codegen

[Ruby, PHP] Errors with slashes in pattern

Open

#3703 aperta il 1 set 2016

Vedi su GitHub
 (8 commenti) (2 reazioni) (0 assegnatari)HTML (5474 fork)batch import
Client: PHPClient: RubyIssue: Bughelp wanted

Metriche repository

Star
 (12.701 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor