explicit 0.2.16 → 0.2.18
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 +14 -0
- data/lib/explicit/configuration.rb +9 -0
- data/lib/explicit/documentation/output/swagger.rb +5 -3
- data/lib/explicit/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: 336334a1c2bd5bdde4580b2b3712618a7edacf3edfec03d1f96c44f704b09c3a
|
4
|
+
data.tar.gz: d756447ce81a13fb7bb7d722bdf7b89221bd556d16ea79bbe2dd39af3bda5e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e574720e293d3bd0b1ed92a0a19dd83a8b1aa4fea48a2e2b3c1d5cffc2ead2a8d87bebabd5815a6d9752b4dee11a70f37a32f438f0c635e8b7f04015802d597d
|
7
|
+
data.tar.gz: d8c7391dd7b6f0a769d885984a2bb823784d7423540e6b07a4e2136d4ac2fe50e42ecc42b120bc3f687244755bc12539278d5f73f21e0c85e8f01325c973606c
|
data/README.md
CHANGED
@@ -45,6 +45,7 @@ documented types at runtime.
|
|
45
45
|
- [Customizing error messages](#customizing-error-messages)
|
46
46
|
- [Customizing error serialization](#customizing-error-serialization)
|
47
47
|
- [Raise on invalid example](#raise-on-invalid-example)
|
48
|
+
- [CORS](#cors)
|
48
49
|
|
49
50
|
# Installation
|
50
51
|
|
@@ -841,7 +842,20 @@ end
|
|
841
842
|
|
842
843
|
### Raise on invalid example
|
843
844
|
|
845
|
+
When adding a request example with `example(params:, response:)`, the response
|
846
|
+
must match the documented types. If it doesn't match, Explicit logs a warning,
|
847
|
+
but you can choose a more strict behaviour that raises an error instead.
|
848
|
+
|
844
849
|
```ruby
|
845
850
|
config.raise_on_invalid_example = true # default is false
|
846
851
|
config.raise_on_invalid_example = ::Rails.env.development? # recommended
|
847
852
|
```
|
853
|
+
|
854
|
+
### CORS
|
855
|
+
|
856
|
+
Enable/disable [CORS headers](https://github.com/luizpvas/explicit/blob/main/lib/explicit/documentation/output/swagger.rb#L67-L74)
|
857
|
+
support.
|
858
|
+
|
859
|
+
```ruby
|
860
|
+
config.cors_enabled = true
|
861
|
+
```
|
@@ -6,6 +6,7 @@ module Explicit
|
|
6
6
|
class Configuration
|
7
7
|
def initialize
|
8
8
|
@rescue_from_invalid_params = true
|
9
|
+
@cors_enabled = !defined?(::Rack::Cors)
|
9
10
|
end
|
10
11
|
|
11
12
|
def request_examples_file_path=(path)
|
@@ -36,6 +37,14 @@ module Explicit
|
|
36
37
|
@raise_on_invalid_example
|
37
38
|
end
|
38
39
|
|
40
|
+
def cors_enabled=(enabled)
|
41
|
+
@cors_enabled = enabled
|
42
|
+
end
|
43
|
+
|
44
|
+
def cors_enabled?
|
45
|
+
@cors_enabled
|
46
|
+
end
|
47
|
+
|
39
48
|
def test_runner=(test_runner)
|
40
49
|
@test_runner = test_runner
|
41
50
|
end
|
@@ -65,6 +65,8 @@ module Explicit::Documentation::Output
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def cors_access_control_headers
|
68
|
+
return {} if !::Explicit.configuration.cors_enabled?
|
69
|
+
|
68
70
|
{
|
69
71
|
"Access-Control-Allow-Origin" => "*",
|
70
72
|
"Access-Control-Allow-Methods" => "GET, OPTIONS",
|
@@ -156,7 +158,7 @@ module Explicit::Documentation::Output
|
|
156
158
|
in: "header",
|
157
159
|
required: type.required?,
|
158
160
|
schema: type.swagger_schema,
|
159
|
-
style: "
|
161
|
+
style: "form"
|
160
162
|
}
|
161
163
|
end
|
162
164
|
|
@@ -167,7 +169,7 @@ module Explicit::Documentation::Output
|
|
167
169
|
in: "path",
|
168
170
|
required: type.required?,
|
169
171
|
schema: type.swagger_schema,
|
170
|
-
style: "
|
172
|
+
style: "form"
|
171
173
|
}
|
172
174
|
end
|
173
175
|
|
@@ -178,7 +180,7 @@ module Explicit::Documentation::Output
|
|
178
180
|
in: "query",
|
179
181
|
required: type.required?,
|
180
182
|
schema: type.swagger_schema,
|
181
|
-
style: "
|
183
|
+
style: "form"
|
182
184
|
}
|
183
185
|
end
|
184
186
|
|
data/lib/explicit/version.rb
CHANGED