oas_parser 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9110cf5aa4a2d8a2a48ddd895fa6f022f3b58dd1
4
- data.tar.gz: 70e5357430309ed3d4317de5a7a79e109ea045bd
3
+ metadata.gz: 7621b9bf0c9a6613ec55ae5e28455a9bf3027290
4
+ data.tar.gz: f7c08c893f7bb1ade6f3ab34d96e6c97a5fa184c
5
5
  SHA512:
6
- metadata.gz: 6f78415f5deb0af71f6f3e05074e5f239ebe5c31fef5ff25a2f4a593e802f719d4e4d49f7fccc9aa8d59e456bad7ede1eba213f561225d784f7c7b23b5e28240
7
- data.tar.gz: d3e9334eafd9039a9c1fb356c561b3185d465217ba56a78a3ce55e0951e567d1a6c821bce62feb88d4fa4b3fd4d12a287c72a4c9e730c7bd9ad166d5d91d75cb
6
+ metadata.gz: 42643290ad8e381f90600da01b15ae04c706c33128f746c537ba2c9ef7999f55f261a60fb54ed77907cf179142c118a58befdb5a79b414cb9defd95f0e133569
7
+ data.tar.gz: 52e6ba6b817e39fdb4745629038b0210fbd2b82c3b9444f9ea33169de7d2ce0694cd9cd8373d1d5ad1e304d1a3723c14eca133a81e044b7d6cda7be8b5b8b3e4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oas_parser (0.2.0)
4
+ oas_parser (0.3.0)
5
5
  activesupport (~> 5.1.2)
6
6
  addressable (~> 2.3)
7
7
  builder (~> 3.2.3)
@@ -31,6 +31,11 @@ module OasParser
31
31
  end
32
32
  end
33
33
 
34
+ xml_document.xpath('//__text').each do |attribute|
35
+ value = attribute.children.last.content
36
+ attribute.parent.content = value
37
+ end
38
+
34
39
  xml_document.xpath('//__attributes').each(&:remove)
35
40
 
36
41
  xml_document.to_xml.each_line.reject { |x| x.strip == '' }.join
@@ -75,9 +80,15 @@ module OasParser
75
80
  elsif object['properties']
76
81
  o = {}
77
82
  object['properties'].each do |key, value|
78
- if @mode == 'xml' && is_xml_attribute?(value)
79
- o['__attributes'] ||= {}
80
- o['__attributes'][key] = parameter_value(value)
83
+ if @mode == 'xml'
84
+ if is_xml_attribute?(value)
85
+ o['__attributes'] ||= {}
86
+ o['__attributes'][key] = parameter_value(value)
87
+ end
88
+
89
+ if is_xml_text?(value)
90
+ o['__text'] = parameter_value(value)
91
+ end
81
92
  end
82
93
 
83
94
  o[key] = parameter_value(value)
@@ -145,5 +156,12 @@ module OasParser
145
156
  return false unless has_xml_options?(object)
146
157
  object['xml']['attribute'] || false
147
158
  end
159
+
160
+ def is_xml_text?(object)
161
+ # See: https://github.com/OAI/OpenAPI-Specification/issues/630#issuecomment-350680346
162
+ return false unless has_xml_options?(object)
163
+ return true if object['xml']['text'] || false
164
+ object['xml']['x-text'] || false
165
+ end
148
166
  end
149
167
  end
@@ -1,3 +1,3 @@
1
1
  module OasParser
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Butler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable