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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ea020d82544c742432038439630cad304e496fb33335e44de226db513feacbe
4
- data.tar.gz: f733ee198a502d8962e5e726527153f28e924e275ddbe7f965e7b8dc89ee74f9
3
+ metadata.gz: 336334a1c2bd5bdde4580b2b3712618a7edacf3edfec03d1f96c44f704b09c3a
4
+ data.tar.gz: d756447ce81a13fb7bb7d722bdf7b89221bd556d16ea79bbe2dd39af3bda5e05
5
5
  SHA512:
6
- metadata.gz: 31c95c4c1751c84cc4e02a2141bc209005700ac8aba906caecfbaf38193e92d43ad42832bd37a844487ccfc0f7ed433689e078545baf5b35d2db267bff419eff
7
- data.tar.gz: fcbdf61db1ed115b8d0e8c28ff0ba7ea434f4c6c4096dda5e3b238777709a2797d4279906deba7cea11364b90ee2bb43bfeb4b846aad12098b1f2ce84ae6c0de
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: "simple"
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: "simple"
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: "simple"
183
+ style: "form"
182
184
  }
183
185
  end
184
186
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Explicit
4
- VERSION = "0.2.16"
4
+ VERSION = "0.2.18"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explicit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Vasconcellos