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

貢獻者指南