Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 4.2.1

- Fix deprecation warnings when using multi_json >= 1.21. openapi_first now uses `MultiJSON.parse`/`MultiJSON.generate` if available ([#508](https://github.com/ahx/openapi_first/issues/508)).

## 4.2.0

- Added `config.regexp_resolver` configuration option, `'ruby'` (default) or `'ecma'` (also as Symbol). The value is passed to json_schemer's `regexp_resolver` configuration. In OpenAPI, the pattern keyword specifies a regular expression that must conform to the ECMA-262 standard. So using `'ecma'` is recommended.
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
openapi_first (4.2.0)
openapi_first (4.2.1)
drb (~> 2.0)
hana (~> 1.3)
json_schemer (>= 2.1, < 3.0)
Expand Down Expand Up @@ -92,7 +92,7 @@ GEM
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
crass (1.0.7)
date (3.5.1)
date (3.6.0)
diff-lcs (1.6.2)
drb (2.2.3)
erb (6.0.7)
Expand All @@ -108,7 +108,7 @@ GEM
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (3.0.2)
json (3.1.0)
json_schemer (2.5.0)
bigdecimal
hana (~> 1.3)
Expand All @@ -132,7 +132,7 @@ GEM
drb (~> 2.0)
prism (~> 1.5)
mustermann (3.1.1)
net-imap (0.6.7)
net-imap (0.6.8)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -152,7 +152,7 @@ GEM
racc
pp (0.6.4)
prettyprint
prettyprint (0.2.0)
prettyprint (0.2.1)
prism (1.9.0)
racc (1.8.1)
rack (3.2.7)
Expand Down Expand Up @@ -224,14 +224,14 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.7)
rubocop (1.91.0)
rubocop (1.92.0)
json (>= 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
regexp_parser (>= 2.11.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
Expand Down Expand Up @@ -264,7 +264,7 @@ GEM
unicode-display_width (3.3.0)
unicode-emoji (~> 4.3)
unicode-emoji (4.3.0)
uri (1.1.1)
uri (1.1.2)
useragent (0.16.11)
websocket-driver (0.8.2)
base64
Expand Down
1 change: 1 addition & 0 deletions Gemfile.multi_json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem 'multi_json'

group :test, :development do
gem 'actionpack'
gem 'benchmark'
gem 'bundler'
gem 'minitest'
gem 'rack-test'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.rack2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem 'rack', '< 3.0.0'

group :test, :development do
gem 'actionpack'
gem 'benchmark'
gem 'bundler'
gem 'minitest'
gem 'rack-test'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.rack30
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem 'rack', '>= 3.0.0', '< 3.1.0'

group :test, :development do
gem 'actionpack'
gem 'benchmark'
gem 'bundler'
gem 'minitest'
gem 'rack-test'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.rails6
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gemspec
gem 'rackup'

group :test, :development do
gem 'benchmark'
gem 'bundler'
gem 'minitest'
gem 'rack-test'
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
openapi_first (4.2.0)
openapi_first (4.2.1)
drb (~> 2.0)
hana (~> 1.3)
json_schemer (>= 2.1, < 3.0)
Expand Down Expand Up @@ -32,7 +32,7 @@ GEM
memory_profiler (1.1.0)
mustermann (3.1.1)
nio4r (2.7.5)
openapi_parser (2.3.1)
openapi_parser (2.4.0)
optparse (0.8.1)
profile-viewer (0.0.7)
optparse
Expand All @@ -58,7 +58,7 @@ GEM
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
tilt (2.9.0)
uri (1.1.1)
uri (1.1.2)
vernier (1.11.0)
webrick (1.9.2)

Expand Down
21 changes: 12 additions & 9 deletions lib/openapi_first/json.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# frozen_string_literal: true

# This tries to load MultiJson if available to keep compatibility
# with MultiJson until next major version
# with MultiJson

begin
require 'multi_json'

module OpenapiFirst
# Compatibility with MultiJson
# @visibility private
module JSON
ParserError = MultiJson::ParseError

def self.parse(string)
MultiJson.load(string)
end

def self.generate(object)
MultiJson.dump(object)
if defined?(::MultiJSON)
# multi_json >= 1.21.0
ParserError = MultiJSON::ParseError
def self.parse(string) = MultiJSON.parse(string)
def self.generate(object) = MultiJSON.generate(object)
else
# multi_json < 1.21.0
ParserError = MultiJson::ParseError
def self.parse(string) = MultiJson.load(string)
def self.generate(object) = MultiJson.dump(object)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/openapi_first/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module OpenapiFirst
VERSION = '4.2.0'
VERSION = '4.2.1'
end
4 changes: 2 additions & 2 deletions spec/file_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
require 'multi_json'
# :nocov:
before do
MultiJson.load_options = { symbolize_keys: true }
MultiJSON.parse_options = { symbolize_names: true }
end

after do
MultiJson.load_options = { symbolize_keys: false }
MultiJSON.parse_options = { symbolize_names: false }
end
# :nocov:
rescue LoadError # rubocop:disable Lint/SuppressedException
Expand Down
4 changes: 2 additions & 2 deletions spec/openapi_first_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@
require 'multi_json'
# :nocov:
before do
MultiJson.load_options = { symbolize_keys: true }
MultiJSON.parse_options = { symbolize_names: true }
end

after do
MultiJson.load_options = { symbolize_keys: false }
MultiJSON.parse_options = { symbolize_names: false }
end
# :nocov:
rescue LoadError # rubocop:disable Lint/SuppressedException
Expand Down
Loading