From 87852d9246d14e8c8f76ae7351088f31916b9126 Mon Sep 17 00:00:00 2001 From: Andreas Haller Date: Mon, 19 Oct 2026 10:53:27 +0200 Subject: [PATCH 1/2] Add 'benchmark' gem, which no longer ships with ruby 4 --- Gemfile.multi_json | 1 + Gemfile.rack2 | 1 + Gemfile.rack30 | 1 + Gemfile.rails6 | 1 + 4 files changed, 4 insertions(+) diff --git a/Gemfile.multi_json b/Gemfile.multi_json index 5990aa5c..1ec73843 100644 --- a/Gemfile.multi_json +++ b/Gemfile.multi_json @@ -8,6 +8,7 @@ gem 'multi_json' group :test, :development do gem 'actionpack' + gem 'benchmark' gem 'bundler' gem 'minitest' gem 'rack-test' diff --git a/Gemfile.rack2 b/Gemfile.rack2 index 3affc8e2..37d7e378 100644 --- a/Gemfile.rack2 +++ b/Gemfile.rack2 @@ -8,6 +8,7 @@ gem 'rack', '< 3.0.0' group :test, :development do gem 'actionpack' + gem 'benchmark' gem 'bundler' gem 'minitest' gem 'rack-test' diff --git a/Gemfile.rack30 b/Gemfile.rack30 index 5290722d..e74622c4 100644 --- a/Gemfile.rack30 +++ b/Gemfile.rack30 @@ -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' diff --git a/Gemfile.rails6 b/Gemfile.rails6 index f02662c4..7fc032c9 100644 --- a/Gemfile.rails6 +++ b/Gemfile.rails6 @@ -7,6 +7,7 @@ gemspec gem 'rackup' group :test, :development do + gem 'benchmark' gem 'bundler' gem 'minitest' gem 'rack-test' From d7ffc6b29e3b49a4df2768e08cdfc1e37b8e4e94 Mon Sep 17 00:00:00 2001 From: Andreas Haller Date: Mon, 19 Oct 2026 11:20:14 +0200 Subject: [PATCH 2/2] Resolve deprecation warning when using multi_json >= 1.21.0 Closes https://github.com/ahx/openapi_first/issues/508 TODO: Remove multi_json compat in next major version! --- CHANGELOG.md | 4 ++++ Gemfile.lock | 16 ++++++++-------- benchmarks/Gemfile.lock | 6 +++--- lib/openapi_first/json.rb | 21 ++++++++++++--------- lib/openapi_first/version.rb | 2 +- spec/file_loader_spec.rb | 4 ++-- spec/openapi_first_spec.rb | 4 ++-- 7 files changed, 32 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4fdbe85..c49e01ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Gemfile.lock b/Gemfile.lock index 589b22ad..e36173da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/benchmarks/Gemfile.lock b/benchmarks/Gemfile.lock index 9afb1370..b62d5af7 100644 --- a/benchmarks/Gemfile.lock +++ b/benchmarks/Gemfile.lock @@ -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) @@ -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 @@ -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) diff --git a/lib/openapi_first/json.rb b/lib/openapi_first/json.rb index 81eefee7..68a1c2b3 100644 --- a/lib/openapi_first/json.rb +++ b/lib/openapi_first/json.rb @@ -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 diff --git a/lib/openapi_first/version.rb b/lib/openapi_first/version.rb index 7d5814fd..0ec5a1b6 100644 --- a/lib/openapi_first/version.rb +++ b/lib/openapi_first/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module OpenapiFirst - VERSION = '4.2.0' + VERSION = '4.2.1' end diff --git a/spec/file_loader_spec.rb b/spec/file_loader_spec.rb index 4ec85e2a..d7e03e84 100644 --- a/spec/file_loader_spec.rb +++ b/spec/file_loader_spec.rb @@ -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 diff --git a/spec/openapi_first_spec.rb b/spec/openapi_first_spec.rb index 60e361c5..9102df49 100644 --- a/spec/openapi_first_spec.rb +++ b/spec/openapi_first_spec.rb @@ -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