swagger-api/swagger-codegen
Voir sur GitHub[Ruby, PHP] Errors with slashes in pattern
Open
#3 703 ouverte le 1 sept. 2016
Client: PHPClient: RubyIssue: Bughelp wanted
Métriques du dépôt
- Stars
- (12 701 stars)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
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