openapi-ruby 3.4.0 → 3.5.0
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 +4 -4
- data/README.md +5 -3
- data/lib/openapi_ruby/generator/rake_task_support.rb +1 -1
- data/lib/openapi_ruby/version.rb +1 -1
- data/lib/openapi_ruby.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fd91990e73c6bcd5fae00558bb63afd1c4999de976b16d542aa495ddf2ad6a4
|
|
4
|
+
data.tar.gz: 19391cec8179b314284b51afa6adc977849f75aa431a7ec54df70f29b9877e45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9384c41d176a5cdf12a8164a148e8ff0a853aa15c73b06efb4f32bc96d40aaa18d4667c93ab6db863bf12de8eac783308a232a99dad66f755b3e1141ad456e5
|
|
7
|
+
data.tar.gz: c6d8b92d8473ac2f2582632c93d1f5d72fc41645b3c34a0b88192530d0bd1808aef836ac99b8864a92a88cb0587a89f1b0cf867811190e2758fdb86900e25552
|
data/README.md
CHANGED
|
@@ -481,7 +481,7 @@ Two things to set up on the consumer side so the two test frameworks don't both
|
|
|
481
481
|
|
|
482
482
|
```ruby
|
|
483
483
|
# test/test_helper.rb
|
|
484
|
-
unless
|
|
484
|
+
unless OpenapiRuby.schema_generating?
|
|
485
485
|
require "rails/test_help"
|
|
486
486
|
# ...other test-time setup...
|
|
487
487
|
end
|
|
@@ -489,13 +489,15 @@ end
|
|
|
489
489
|
|
|
490
490
|
```ruby
|
|
491
491
|
# spec/rails_helper.rb
|
|
492
|
-
unless
|
|
492
|
+
unless OpenapiRuby.schema_generating?
|
|
493
493
|
require "rspec/rails"
|
|
494
494
|
# ...other spec-time setup...
|
|
495
495
|
end
|
|
496
496
|
```
|
|
497
497
|
|
|
498
|
-
|
|
498
|
+
`OpenapiRuby.schema_generating?` returns `true` when the rake task launched the current process (it sets `OPENAPI_RUBY_GENERATING=true` in the subprocess). With the guards in place, neither test framework boots its full Rails integration during generation — only the DSL needs to be live for `api_path` / `path` to register.
|
|
499
|
+
|
|
500
|
+
The guards are only needed while both frameworks are live. Once the migration completes and only one test framework remains, the rake task auto-detects that framework and the guard becomes dead code that can be removed.
|
|
499
501
|
|
|
500
502
|
## Runtime Middleware
|
|
501
503
|
|
|
@@ -63,7 +63,7 @@ module OpenapiRuby
|
|
|
63
63
|
# during a phased RSpec → Minitest migration where the suite
|
|
64
64
|
# holds both DSL styles. Consumers should guard
|
|
65
65
|
# `require "rails/test_help"` and `require "rspec/rails"` in
|
|
66
|
-
# their test helpers with `unless
|
|
66
|
+
# their test helpers with `unless OpenapiRuby.schema_generating?`
|
|
67
67
|
# so the two test frameworks don't both register Rails lazy
|
|
68
68
|
# hooks in the same process — only the DSL needs to be live for
|
|
69
69
|
# schema generation.
|
data/lib/openapi_ruby/version.rb
CHANGED
data/lib/openapi_ruby.rb
CHANGED
|
@@ -27,6 +27,22 @@ module OpenapiRuby
|
|
|
27
27
|
def reset_configuration!
|
|
28
28
|
@configuration = Configuration.new
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
# True when the current process was started by `openapi_ruby:generate`
|
|
32
|
+
# (the rake task sets OPENAPI_RUBY_GENERATING=true in the subprocess).
|
|
33
|
+
#
|
|
34
|
+
# Useful in consumer test helpers to guard test-framework requires
|
|
35
|
+
# that conflict when both `rspec/rails` and `rails/test_help` load
|
|
36
|
+
# in the same process (the FRAMEWORK=hybrid case):
|
|
37
|
+
#
|
|
38
|
+
# # test/test_helper.rb
|
|
39
|
+
# unless OpenapiRuby.schema_generating?
|
|
40
|
+
# require "rails/test_help"
|
|
41
|
+
# # ...other test-time setup...
|
|
42
|
+
# end
|
|
43
|
+
def schema_generating?
|
|
44
|
+
ENV["OPENAPI_RUBY_GENERATING"] == "true"
|
|
45
|
+
end
|
|
30
46
|
end
|
|
31
47
|
end
|
|
32
48
|
|