explicit 0.2.6 → 0.2.7
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 +2 -0
- data/lib/explicit/documentation/builder.rb +1 -0
- data/lib/explicit/documentation/output/webpage.rb +6 -4
- data/lib/explicit/test_helper.rb +10 -2
- 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: b817ec6fe610ab86d5938a0b7958633f4f34e68a4d02b9bd8c8a50bf831622bc
|
4
|
+
data.tar.gz: 8cb2aae4e5a1d582734b6e1f4a917f0b07b4cf4839932dd1e2a5754f3320663b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e385f89b47ec351fb000f5b9097d5ccf6233ac01dd57b9e07e87ac9488718528655ef7033686dc482dd9fc9812063f64c1f79313492157dd3ecad63055ff01b
|
7
|
+
data.tar.gz: 5fefc99c8c881d334364102f17e9cab4247bf0486dd5744e041654e83354e2b0265dbfaf2f41f185b354370356c33823c036b13fc2010db459e998ae0ba436ef
|
data/README.md
CHANGED
@@ -255,6 +255,8 @@ documentation for your API. The following methods are available:
|
|
255
255
|
|
256
256
|
- `page_title(text)` - Sets the web page title.
|
257
257
|
- `company_logo_url(url)` - Shows the company logo in the navigation menu.
|
258
|
+
The url can also be a lambda that returns the url, useful for referencing
|
259
|
+
assets at runtime.
|
258
260
|
- `favicon_url(url)` - Adds a favicon to the web page.
|
259
261
|
- `version(semver)` - Sets the version of the API. Default: "1.0"
|
260
262
|
- `section(name, &block)` - Adds a section to the navigation menu.
|
@@ -59,6 +59,7 @@ module Explicit::Documentation
|
|
59
59
|
|
60
60
|
def merge_request_examples_from_file!
|
61
61
|
return if !Explicit.configuration.request_examples_file_path
|
62
|
+
return if !::File.exist?(Explicit.configuration.request_examples_file_path)
|
62
63
|
|
63
64
|
encoded = ::File.read(Explicit.configuration.request_examples_file_path)
|
64
65
|
|
@@ -19,15 +19,17 @@ module Explicit::Documentation::Output
|
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
+
Eval = ->(value) { value.respond_to?(:call) ? value.call : value }
|
23
|
+
|
22
24
|
def render_documentation_page
|
23
25
|
Explicit::ApplicationController.render(
|
24
26
|
partial: "explicit/documentation/page",
|
25
27
|
locals: {
|
26
28
|
url_helpers: @builder.rails_engine.routes.url_helpers,
|
27
|
-
page_title: builder.get_page_title,
|
28
|
-
company_logo_url: builder.get_company_logo_url,
|
29
|
-
favicon_url: builder.get_favicon_url,
|
30
|
-
version: builder.get_version,
|
29
|
+
page_title: Eval[builder.get_page_title],
|
30
|
+
company_logo_url: Eval[builder.get_company_logo_url],
|
31
|
+
favicon_url: Eval[builder.get_favicon_url],
|
32
|
+
version: Eval[builder.get_version],
|
31
33
|
sections: builder.sections,
|
32
34
|
}
|
33
35
|
)
|
data/lib/explicit/test_helper.rb
CHANGED
@@ -50,9 +50,13 @@ module Explicit::TestHelper
|
|
50
50
|
end
|
51
51
|
|
52
52
|
method = route.method
|
53
|
+
path = (request.get_base_path || "") + route.replace_path_params(params)
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
if missing_path_param?(route, params)
|
56
|
+
raise <<~DESC
|
57
|
+
The request #{route} needs the following path parameters: #{route.params.join(", ")}
|
58
|
+
DESC
|
59
|
+
end
|
56
60
|
|
57
61
|
process(method, path, params:, headers:)
|
58
62
|
|
@@ -90,6 +94,10 @@ module Explicit::TestHelper
|
|
90
94
|
response
|
91
95
|
end
|
92
96
|
|
97
|
+
def missing_path_param?(route, params)
|
98
|
+
route.params.any? { params.fetch(_1, nil).nil? }
|
99
|
+
end
|
100
|
+
|
93
101
|
def ensure_response_matches_documented_type!(request, response)
|
94
102
|
responses_type = request.responses_type(status: response.status)
|
95
103
|
|
data/lib/explicit/version.rb
CHANGED