oas_core 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b7fff636be925e25278a987158cc802337d3e90560a958aa18aad4197f97a06
4
- data.tar.gz: 011c393af762dc61e60fb6a823e625145f2a9bf1addfce5edfb9eb0a901b4b10
3
+ metadata.gz: fe76304fe743cec241e26b3b45d23ab4ec0ab6d541b13805cbe7e6d19bc65f27
4
+ data.tar.gz: b12c225f74e15fa422de9c8ec0867359b6c08a83ad12527dbe12c01229b6ba37
5
5
  SHA512:
6
- metadata.gz: d3efcb0f75eb82138df3bb61b9fdccffc721744a490dd63cc18db4897ef24a84eff84169d60df774d3011ca45f5f2ef86635d3019e980d08bea61b9b5505d2c2
7
- data.tar.gz: b15ff547e983d889c2d651d2367d623bef5ef0697c7288df721922c65553e16576f459739c1de2c951d9fc95db66241a506ecb975377167701fb2bb06c197d3b
6
+ metadata.gz: a159cdecefb67ccb2eece07a28075f2be94d0f49d41a8097646c7508c44697bdcde29055f680d14fe61da3bfa9032a2b1746872e08b2972504c9e9ca0a494560
7
+ data.tar.gz: 0c34801baaf804d676bf10ae9c6d67df48733285024084d8f58bdb384e9d04b72c06ad1bd4a4815413cbb5e9e775fc5bcad993c1713175539aa868b473fa7066
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OasCore
4
- VERSION = '1.4.1'
4
+ VERSION = '1.4.2'
5
5
  end
@@ -190,8 +190,7 @@ module OasCore
190
190
  # @return [Hash] The processed content.
191
191
  def raw_type_to_content(raw_type)
192
192
  if raw_type.start_with?('JSON')
193
- json_string = raw_type.sub(/^JSON/, '').gsub(/'/, '"')
194
- JSON.parse(json_string)
193
+ parse_json_content(raw_type.sub(/^JSON/, ''))
195
194
  elsif raw_type.start_with?('Reference:')
196
195
  ref = raw_type.sub(/^Reference:/, '').strip
197
196
  OasCore::Spec::Reference.new(ref)
@@ -200,6 +199,18 @@ module OasCore
200
199
  end
201
200
  end
202
201
 
202
+ # Parses the body of a JSON example. Valid JSON is taken as written, so
203
+ # string values may contain apostrophes ("the request's origin"). The
204
+ # single-quote convenience (JSON{'key': 'value'}) is kept as a fallback
205
+ # for input that does not parse as strict JSON.
206
+ # @param json_string [String] The example body after the JSON prefix.
207
+ # @return [Hash] The parsed content.
208
+ def parse_json_content(json_string)
209
+ JSON.parse(json_string)
210
+ rescue JSON::ParserError
211
+ JSON.parse(json_string.gsub(/'/, '"'))
212
+ end
213
+
203
214
  # Parses the position name and location from input text.
204
215
  # @param input [String] The input text to parse.
205
216
  # @return [Array] An array containing the name and location.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-chacon