[ruby] Generated client has a syntax-error
Created by: meganemura
Description
As I described in https://github.com/OpenAPITools/openapi-generator/pull/1482#issuecomment-439669221,
I found that the generated ruby-client for OpenAPI 2.0 has a syntax-error.
> Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)
Traceback (most recent call last):
1: from /Users/meganemura/.rbenv/versions/2.5.3/bin/irb:11:in `<main>'
SyntaxError ((irb):1: premature end of char-class: /^(?:[A-Za-z0-9+/)
(irb):1: syntax error, unexpected ']', expecting ')'
Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A...
https://github.com/OpenAPITools/openapi-generator/blob/9be5b9926694f929c450040312d7b90fde625b0d/samples/client/petstore/ruby/lib/petstore/models/format_test.rb#L198 https://github.com/OpenAPITools/openapi-generator/blob/9be5b9926694f929c450040312d7b90fde625b0d/samples/client/petstore/ruby/lib/petstore/models/format_test.rb#L237 https://github.com/OpenAPITools/openapi-generator/blob/9be5b9926694f929c450040312d7b90fde625b0d/samples/client/petstore/ruby/lib/petstore/models/format_test.rb#L336
We want to treat regex properly in the following pattern (from #1392 (closed)):
In OpenAPI v3 file: pattern: '^\d{10}$'
Generated validation code: Regexp.new(/^\\d{10}$/)
Should be: Regexp.new(/^\d{10}$/)
So, the fix of #1393 adds slash(es) to the strings, but didn't work when the pattern contains /
like this situation.
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
- #1392 (closed)
- #1393
/cc @ggershoni
Suggest a fix/enhancement
Let me think about it.