Skip to content

Commit f52bda4

Browse files
authored
Merge pull request #5 from MarioRuiz/0.10.9
close #4
2 parents 0b0244e + f96a1f3 commit f52bda4

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/open_api_import.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,8 @@ class << self
925925
if dpv[:pattern].include?('\\\\/')
926926
#for cases like this: ^[^\.\\/:*?"<>|][^\\/:*?"<>|]{0,13}[^\.\\/:*?"<>|]?$
927927
data_pattern << "'#{dpk}': /#{dpv[:pattern].to_s.gsub('\/','/')}/"
928+
elsif dpv[:pattern].include?('\\x')
929+
data_pattern << "'#{dpk}': /#{dpv[:pattern].to_s.gsub('\\x','\\u')}/"
928930
else
929931
data_pattern << "'#{dpk}': /#{dpv[:pattern].to_s}/"
930932
end

open_api_import.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'open_api_import'
3-
s.version = '0.10.8'
3+
s.version = '0.10.9'
44
s.summary = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML"
55
s.description = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML"
66
s.authors = ["Mario Ruiz"]

spec/fixtures/v2.0/yaml/petstore.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ definitions:
8383
format: int64
8484
name:
8585
type: string
86+
pattern: ^[a-z\x00DF-\x00FF][a-z0-9\-_\x{DF}-\x{FF}]*$
8687
tag:
8788
type: string
8889
Pets:

spec/open_api_import/open_api_import_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,20 @@
238238
expect(content).to include('def self.get_products(latitude: LATITUDE, longitude: LONGITUDE)')
239239
end
240240

241+
it 'converts patterns from \\x to \\u' do
242+
file_name = './spec/fixtures/v2.0/yaml/petstore.yaml'
243+
File.delete("#{file_name}.rb") if File.exist?("#{file_name}.rb")
244+
OpenApiImport.from file_name, create_method_name: :operation_id
245+
expect(File.exist?("#{file_name}.rb")).to eq true
246+
content = File.read("#{file_name}.rb")
247+
eval(content)
248+
req = Swagger::SwaggerPetstore::V1_0_0::Root.list_pets
249+
expect(req.key?(:data_pattern)).to eq true
250+
expect(req[:data_pattern].key?(:name)).to eq true
251+
expect(req[:data_pattern][:name].to_s).to eq '(?-mix:^[a-z\u00DF-\u00FF][a-z0-9\-_\u{DF}-\u{FF}]*$)'
252+
end
253+
254+
241255
end
242256

243257

0 commit comments

Comments
 (0)