explicit 0.2.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5c59437da284708551b719ae8b40a62e98e38886b6327807edef311068b7634
4
- data.tar.gz: 9175b15ba7d61853e56ec823a781565b413886793f32efeb8f5ae37459511ff4
3
+ metadata.gz: b817ec6fe610ab86d5938a0b7958633f4f34e68a4d02b9bd8c8a50bf831622bc
4
+ data.tar.gz: 8cb2aae4e5a1d582734b6e1f4a917f0b07b4cf4839932dd1e2a5754f3320663b
5
5
  SHA512:
6
- metadata.gz: 0ebe27efff3c7a9e1379e2e2025a9c75499905efaa1bdaaacff51ff17e963175e1cfc2d2e81f98f4fce615f6161be792ebad385a38471e2a9901bb076e17f3d3
7
- data.tar.gz: 1da9daabfa4d8e59c85051eff97fce1f9091fb744ec3294403fc7baff972c50cf0b965ea0670f92fe26a9d8bbc01337a8a7631f1a32465e2f8e9ce764f036657
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
  )
@@ -50,7 +50,13 @@ module Explicit::TestHelper
50
50
  end
51
51
 
52
52
  method = route.method
53
- path = (request.get_base_path || "") + route.path
53
+ path = (request.get_base_path || "") + route.replace_path_params(params)
54
+
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
54
60
 
55
61
  process(method, path, params:, headers:)
56
62
 
@@ -88,6 +94,10 @@ module Explicit::TestHelper
88
94
  response
89
95
  end
90
96
 
97
+ def missing_path_param?(route, params)
98
+ route.params.any? { params.fetch(_1, nil).nil? }
99
+ end
100
+
91
101
  def ensure_response_matches_documented_type!(request, response)
92
102
  responses_type = request.responses_type(status: response.status)
93
103
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Explicit
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explicit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Vasconcellos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-12 00:00:00.000000000 Z
11
+ date: 2025-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails