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

Regex param validation not working as expected in Ruby-Client #1392

Closed
ggershoni opened this issue Nov 6, 2018 · 1 comment
Closed

Regex param validation not working as expected in Ruby-Client #1392

ggershoni opened this issue Nov 6, 2018 · 1 comment

Comments

@ggershoni
Copy link
Contributor

ggershoni commented Nov 6, 2018

Description

We are using a \d in our regex to ensure pattern has only digits but this is turned into \d and Ruby can't interpret it correctly.

In OpenAPI v3 file: pattern: '^\d{10}$'
Generated validation code: Regexp.new(/^\\d{10}$/)
Should be: Regexp.new(/^\d{10}$/)

openapi-generator version

Was using latest stable version (3.3.2) and also grabbed and build latest from master.

OpenAPI declaration file content or url
Command line used for generation

docker run --rm -v ${PWD}:/local -v ${PWD}/../openapi/$(OPENAPI_FILENAME):/source/openapi-v3.yaml openapitools/openapi-generator-cli generate -i /source/openapi-v3.yaml -g ruby -o /local/out/ruby-client

Steps to reproduce

Following code is raising exception:

require 'openapi_client'

api_instance = OpenapiClient::AccountsApi.new
account_number = '1234567890'
account_number2 = '1234567891'
authentication = 'authentication_example'

result = api_instance.get_account_information(account_number, account_number2, authentication)
p result
Traceback (most recent call last):
	2: from get_account.rb:8:in `<main>'
	1: from /Users/guy/.gem/ruby/2.5.3/gems/openapi_client-1.0.0/lib/openapi_client/api/accounts_api.rb:29:in `get_account_information'
/Users/guy/.gem/ruby/2.5.3/gems/openapi_client-1.0.0/lib/openapi_client/api/accounts_api.rb:48:in `get_account_information_with_http_info': invalid value for 'account_number' when calling AccountsApi.get_account_information, must conform to the pattern /^\d{10}$/. (ArgumentError)
Related issues/PRs
Suggest a fix/enhancement

Have PR with fix.

wing328 pushed a commit that referenced this issue Nov 7, 2018
…nt. (#1393)

* Added tests and fix for issue #1392. Param validation with regex not recognizing \d correctly in Ruby client.

* Added generated files to pass ./bin/utils/ensure-up-to-date which is run by circleci
@wing328
Copy link
Member

wing328 commented Nov 7, 2018

@ggershoni thanks for the PR, which has been merged into master.

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

No branches or pull requests

2 participants