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 +4 -4
- data/README.md +12 -12
- data/app/controllers/openapi_ruby/ui_controller.rb +0 -4
- data/config/routes.rb +4 -2
- data/lib/generators/openapi_ruby/install/install_generator.rb +2 -2
- data/lib/generators/openapi_ruby/install/templates/initializer.rb.tt +3 -3
- data/lib/openapi_ruby/configuration.rb +2 -3
- data/lib/openapi_ruby/version.rb +1 -1
- 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: b7cf0386d71aab389accfc260a830ee4c5f58260afca19e6a4849163f6aa6661
|
|
4
|
+
data.tar.gz: 904d32c7314c46e68cda32d12740194bda8d25ca0cf177f0a8f4812a6f2e13a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
- `
|
|
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 = "
|
|
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
|
-
|
|
533
|
+
Mount the engine to expose the schema endpoints:
|
|
536
534
|
|
|
537
535
|
```ruby
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
end
|
|
536
|
+
# config/routes.rb
|
|
537
|
+
mount OpenapiRuby::Engine => "/api-docs"
|
|
541
538
|
```
|
|
542
539
|
|
|
543
|
-
|
|
540
|
+
Schema files are served at `/api-docs/schemas/:name`.
|
|
544
541
|
|
|
545
|
-
|
|
542
|
+
To also serve the interactive Swagger UI at the mount root, opt in:
|
|
546
543
|
|
|
547
544
|
```ruby
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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
|
|
@@ -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 = "
|
|
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 (
|
|
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, :
|
|
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 = "
|
|
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
|
data/lib/openapi_ruby/version.rb
CHANGED