openapi-ruby 3.5.2 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 936888de957c1f2de331027e22f12edc490b3a49e4a71cac9aaafcf085f251db
4
- data.tar.gz: 143efa7749ecb7292f52309ee80c3fa7663ccf2cb20387a81fe34d62319181ae
3
+ metadata.gz: b7cf0386d71aab389accfc260a830ee4c5f58260afca19e6a4849163f6aa6661
4
+ data.tar.gz: 904d32c7314c46e68cda32d12740194bda8d25ca0cf177f0a8f4812a6f2e13a7
5
5
  SHA512:
6
- metadata.gz: e8d35b9315e7d357f32704ae303721be1dee960d0d4be01ba1f3ea4939cd2658177480c9e1a70b76909743ad130eabdb02e64f825543df840f1e4e7678ab1bad
7
- data.tar.gz: 1e8ee130cc36c66a5e259e65afda71753c7dbd4a63cab4d6441fd6706c55da429dbafc2723e292f6412d92a4ab072017c69789ed206b875c9f7783b54720147d
6
+ metadata.gz: 38ca153a668606b62a97ea58fb6d74ca0ff95f073e6bbc0dbff831338b9f6bbc79887dbda977bd2daff045fd071d5f4b714beeedf8c5b90440f7f0db54814574
7
+ data.tar.gz: 6239cdcd0dbff05e9f62a6098337e8f675d42ca852c865da755a3f1c4babe031e31eb33f3cde34e28dd9be0f44d392c4c757ce36933ca43a62df74cf19012dcf
data/README.md CHANGED
@@ -44,7 +44,7 @@ This creates:
44
44
  - `config/initializers/openapi_ruby.rb` — configuration
45
45
  - `spec/openapi_helper.rb` or `test/openapi_helper.rb` — test helper
46
46
  - `app/api_components/` — directory for schema components
47
- - `swagger/` — output directory for generated specs
47
+ - `openapi/` — output directory for generated specs
48
48
  - Engine mount in `config/routes.rb`
49
49
 
50
50
  ## Configuration
@@ -61,7 +61,7 @@ OpenapiRuby.configure do |config|
61
61
 
62
62
  config.component_paths = ["app/api_components"]
63
63
  config.camelize_keys = true
64
- config.schema_output_dir = "swagger"
64
+ config.schema_output_dir = "openapi"
65
65
  config.schema_output_format = :yaml
66
66
 
67
67
  # Runtime middleware (disabled by default)
@@ -72,8 +72,6 @@ OpenapiRuby.configure do |config|
72
72
  # Enabled by default; set to false to disable.
73
73
  config.test_request_validation = true
74
74
 
75
- # Optional Swagger UI (disabled by default)
76
- config.ui_enabled = false
77
75
  end
78
76
  ```
79
77
 
@@ -532,23 +530,25 @@ config.schemas = {
532
530
 
533
531
  ## Swagger UI
534
532
 
535
- Enable optional Swagger UI:
533
+ Mount the engine to expose the schema endpoints:
536
534
 
537
535
  ```ruby
538
- OpenapiRuby.configure do |config|
539
- config.ui_enabled = true
540
- end
536
+ # config/routes.rb
537
+ mount OpenapiRuby::Engine => "/api-docs"
541
538
  ```
542
539
 
543
- Visit `/api-docs/ui` to see your API documentation. Schema files are served at `/api-docs/schemas/:name`.
540
+ Schema files are served at `/api-docs/schemas/:name`.
544
541
 
545
- ## Engine Routes
542
+ To also serve the interactive Swagger UI at the mount root, opt in:
546
543
 
547
544
  ```ruby
548
- # config/routes.rb
549
- mount OpenapiRuby::Engine => "/api-docs"
545
+ OpenapiRuby.configure do |config|
546
+ config.ui_enabled = true
547
+ end
550
548
  ```
551
549
 
550
+ Then visit `/api-docs` for the UI. When `ui_enabled` is `false` (the default), `/api-docs` returns 404 and only the schema endpoints are served — useful when downstream tooling needs the schema but you don't want to expose an interactive explorer.
551
+
552
552
  ## License
553
553
 
554
554
  MIT
@@ -5,8 +5,6 @@ module OpenapiRuby
5
5
  layout false
6
6
 
7
7
  def index
8
- return head :not_found unless OpenapiRuby.configuration.ui_enabled
9
-
10
8
  config = OpenapiRuby.configuration
11
9
  @schemas = config.schemas
12
10
  @ui_config = config.ui_config
@@ -15,8 +13,6 @@ module OpenapiRuby
15
13
  end
16
14
 
17
15
  def oauth2_redirect
18
- return head :not_found unless OpenapiRuby.configuration.ui_enabled
19
-
20
16
  file = File.join(OpenapiRuby::Engine.root, "app", "views", "openapi_ruby", "oauth2_redirect.html")
21
17
  render file: file, layout: false, content_type: "text/html"
22
18
  end
data/config/routes.rb CHANGED
@@ -4,6 +4,8 @@ OpenapiRuby::Engine.routes.draw do
4
4
  get "schemas", to: "schemas#index", as: :schemas
5
5
  get "schemas/*id", to: "schemas#show", as: :schema
6
6
 
7
- get "ui", to: "ui#index", as: :ui
8
- get "oauth2-redirect.html", to: "ui#oauth2_redirect", as: :oauth2_redirect
7
+ if OpenapiRuby.configuration.ui_enabled
8
+ root to: "ui#index"
9
+ get "oauth2-redirect.html", to: "ui#oauth2_redirect", as: :oauth2_redirect
10
+ end
9
11
  end
@@ -25,8 +25,8 @@ module OpenapiRuby
25
25
  empty_directory "app/api_components/security_schemes"
26
26
  end
27
27
 
28
- def create_swagger_directory
29
- empty_directory "swagger"
28
+ def create_schema_output_directory
29
+ empty_directory "openapi"
30
30
  end
31
31
 
32
32
  def mount_engine
@@ -17,7 +17,7 @@ OpenapiRuby.configure do |config|
17
17
  config.camelize_keys = true
18
18
 
19
19
  # Generated schema output
20
- config.schema_output_dir = "swagger"
20
+ config.schema_output_dir = "openapi"
21
21
  config.schema_output_format = :yaml
22
22
 
23
23
  # Runtime request/response validation middleware
@@ -25,7 +25,7 @@ OpenapiRuby.configure do |config|
25
25
  config.request_validation = :disabled
26
26
  config.response_validation = :disabled
27
27
 
28
- # Swagger UI (optional, disabled by default)
28
+ # Swagger UI at the engine's mount path (disabled by default).
29
+ # When false, only the schema endpoints are served.
29
30
  config.ui_enabled = false
30
- # config.ui_path = "/api-docs"
31
31
  end
@@ -40,7 +40,7 @@ module OpenapiRuby
40
40
  end
41
41
 
42
42
  # UI (optional)
43
- attr_accessor :ui_enabled, :ui_path, :ui_config
43
+ attr_accessor :ui_enabled, :ui_config
44
44
 
45
45
  def initialize
46
46
  @schemas = {}
@@ -51,10 +51,9 @@ module OpenapiRuby
51
51
  @response_validation = :disabled
52
52
  @coerce_params = true
53
53
  @test_request_validation = true
54
- @schema_output_dir = "swagger"
54
+ @schema_output_dir = "openapi"
55
55
  @schema_output_format = :yaml
56
56
  @ui_enabled = false
57
- @ui_path = "/api-docs"
58
57
  @ui_config = {}
59
58
  @strict_reference_validation = :warn_only
60
59
  @auto_validation_error_response = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiRuby
4
- VERSION = "3.5.2"
4
+ VERSION = "4.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Hartvig