Skip to content

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

@ggershoni

Description

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions