From 92aa8ed767f8d442b7ccafdd6e884e3f8072f16a Mon Sep 17 00:00:00 2001 From: Masahiro Saito Date: Mon, 5 Sep 2016 16:37:54 +0900 Subject: [PATCH] [Ruby] Fix ambiguous regex (#3716) * ruby: Fix ambiguous regex * ruby: Add test for strict regex --- .../src/main/resources/ruby/base_object.mustache | 2 +- .../ruby/lib/petstore/models/additional_properties_class.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/animal.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb | 2 +- .../client/petstore/ruby/lib/petstore/models/api_response.rb | 2 +- .../ruby/lib/petstore/models/array_of_array_of_number_only.rb | 2 +- .../petstore/ruby/lib/petstore/models/array_of_number_only.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/array_test.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/cat.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/category.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/client.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/dog.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/enum_test.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/format_test.rb | 2 +- .../petstore/ruby/lib/petstore/models/has_only_read_only.rb | 2 +- .../petstore/ruby/lib/petstore/models/inline_response_200.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/list.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/map_test.rb | 2 +- .../models/mixed_properties_and_additional_properties_class.rb | 2 +- .../petstore/ruby/lib/petstore/models/model_200_response.rb | 2 +- .../client/petstore/ruby/lib/petstore/models/model_return.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/name.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/number_only.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/order.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/pet.rb | 2 +- .../client/petstore/ruby/lib/petstore/models/read_only_first.rb | 2 +- .../petstore/ruby/lib/petstore/models/special_model_name.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/tag.rb | 2 +- samples/client/petstore/ruby/lib/petstore/models/user.rb | 2 +- samples/client/petstore/ruby/spec/base_object_spec.rb | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache index 0c15a9929f3..a28437fc695 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache @@ -35,7 +35,7 @@ when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index 27bb91fea38..b9ee9a3693f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -140,7 +140,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 692c736e98e..24b4788705a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -139,7 +139,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb index 71a87330302..1966d1cb440 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb @@ -118,7 +118,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index e8c413b5b4f..cf9f163d5b3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -145,7 +145,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 779608824ad..fbc3f8df519 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -129,7 +129,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index 6077f9a5584..2e8cc072211 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -129,7 +129,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb index 8a005f1c5cd..1e30d141430 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -151,7 +151,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 8eb06e9ee9f..ca5dfa12dae 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -148,7 +148,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 2edd8b0bbe2..849b0c96dd9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -136,7 +136,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index c7663e0d6c1..186894b8338 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -127,7 +127,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index ceaeb2714e9..5a481c524a6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -148,7 +148,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index 1c56f3a2db2..194aa26460e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -171,7 +171,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index ab6e17324d4..f9c36700349 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -202,7 +202,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 2159b1ea656..4812b7a2cae 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -424,7 +424,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 046325dbced..06c66756d99 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -136,7 +136,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index a3a44b28cfe..442a0e26ed8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -159,7 +159,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index f2f34430ce7..77045dc9f1a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -127,7 +127,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb index e227c9c8cef..5204a2a2316 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -161,7 +161,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index e87726056fe..4c7fbf2e790 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -147,7 +147,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 3a519731281..8e1660ed4b5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -136,7 +136,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 448610807c6..4bd7d792af0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -127,7 +127,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index dd6978fec9a..5d72199e21e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -155,7 +155,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb index 4b70b090df8..07267259fd7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -127,7 +127,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 2b6aa895718..a07a4ba84c9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -208,7 +208,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index b74bba64192..428720d76fc 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -212,7 +212,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb index 3be06c72ffb..d4d36e85cba 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -136,7 +136,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 40e8f2ed692..0cf160271d9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -127,7 +127,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index d7a351d3dbe..0bc268c946a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -136,7 +136,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 5d7467ad970..163874f6416 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -191,7 +191,7 @@ module Petstore when :Float value.to_f when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i + if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false diff --git a/samples/client/petstore/ruby/spec/base_object_spec.rb b/samples/client/petstore/ruby/spec/base_object_spec.rb index 5b84351f7b8..115a1c0e040 100644 --- a/samples/client/petstore/ruby/spec/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/base_object_spec.rb @@ -51,7 +51,7 @@ describe 'BaseObject' do int_arr_map: {'int_arr' => [123, 456]}, pet_arr_map: {'pet_arr' => [{name: 'Kitty'}]}, boolean_true_arr: [true, "true", "TruE", 1, "y", "yes", "1", "t", "T"], - boolean_false_arr: [false, "", 0, "0", "f", nil, "null"], + boolean_false_arr: [false, "", 0, "0", "f", nil, "null", "\ntrue\n"], } end