Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ruby] Generated client has a syntax-error #1520

Closed
meganemura opened this issue Nov 22, 2018 · 0 comments · Fixed by #1521
Closed

[ruby] Generated client has a syntax-error #1520

meganemura opened this issue Nov 22, 2018 · 0 comments · Fixed by #1521

Comments

@meganemura
Copy link
Contributor

meganemura commented Nov 22, 2018

Description

As I described in #1482 (comment),

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...

if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)

return false if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)

if byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$)

We want to treat regex properly in the following pattern (from #1392):

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

/cc @ggershoni

Suggest a fix/enhancement

Let me think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant