swagger-api/swagger-codegen

[Ruby, PHP] Errors with slashes in pattern

オープン

#3,703 opened on 2016/09/01

 (8 件のコメント) (2 件のリアクション) (0 人の担当者)HTML (5,474 件のフォーク)batch import
Client: PHPClient: RubyIssue: Bughelp wanted

Repository metrics

Stars
 (12,701 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド