swagger-api/swagger-codegen

[Ruby, PHP] Errors with slashes in pattern

开放

#3,703 创建于 2016年9月1日

 (8 条评论) (2 个反应) (0 位负责人)HTML (5,474 个派生)batch import
Client: PHPClient: RubyIssue: Bughelp wanted

仓库指标

星标
 (12,701 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南