explicit 0.2.14 → 0.2.15

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: 2d46564124ef78f3d7caaa7985d8ccf95a8eb43ff0dcd2853a36836e29076e8b
4
- data.tar.gz: f13116b827d4574cae5a9476b359cc64ca2ec6e0040db678793e21cce552547e
3
+ metadata.gz: de123083ab64bba09159b8980d3ceb0d838ded515e163d4360129fc7accd4a53
4
+ data.tar.gz: d221e834b71e4d45fec25800ec995bd1a5c25a14a973301047a3b9932033773b
5
5
  SHA512:
6
- metadata.gz: acb499d03d7293a55b419bc8e5df6252520f93972347874868175720eb3654b4ddd75a87b0896a50092e8c325ac98dfcaf25ec36b3115806eba8b15fa7e8aa63
7
- data.tar.gz: cdc1ba59de204f9d9f4d6f26afc7591dd98e3f36d9aa96e571473543d6d4603fb15ecc137882006ad569d911705e0442d2a13ffc19f729307c86c5fb1e8e003a
6
+ metadata.gz: 54a295c83d2df60e452d7088f04d83fb419820190fc6445b3f07593adb01344689d3a95758e1b98a37312cf24d54a6a8c5dbed834c4137f11f51cee2db5096e1
7
+ data.tar.gz: d731ecb3e2e3d305857fa522d6eb9b9889ee8223eff2201f85c8eb62ccd784e0cedabe5bfb1b6c2a56db3b21d64996cfbc001d8140cf55da8d0ac647e9fc4626
@@ -56,7 +56,7 @@
56
56
  Version <%= version %>
57
57
  </div>
58
58
  <div class="p-1 w-1/2">
59
- <%= link_to "https://petstore.swagger.io/?url=#{url_helpers.explicit_documentation_swagger_url(host: request.host)}", target: "_blank", class: "flex items-center justify-center gap-1 text-neutral-900" do %>
59
+ <%= link_to "https://petstore.swagger.io/?url=#{url_helpers.explicit_documentation_swagger_url(host:)}", target: "_blank", class: "flex items-center justify-center gap-1 text-neutral-900" do %>
60
60
  <span>Swagger</span>
61
61
 
62
62
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4">
@@ -1,3 +1,7 @@
1
+ <p>
2
+ A string-encoded decimal number. For example: <code>"123.45"</code>.
3
+ </p>
4
+
1
5
  <%= type_constraints do %>
2
6
  <%= type_constraint "min:", type.min if type.min.present? %>
3
7
  <%= type_constraint "max:", type.max if type.max.present? %>
@@ -43,10 +43,16 @@ module Explicit::Documentation::Output
43
43
  }
44
44
  end
45
45
 
46
- def call(request)
46
+ def call(env)
47
+ return respond_cors_preflight_request if env["REQUEST_METHOD"] == "OPTIONS"
48
+
47
49
  @swagger_document ||= swagger_document
48
50
 
49
- [ 200, { "Content-Type" => "application/json" }, [ @swagger_document.to_json ] ]
51
+ headers = cors_access_control_headers.merge({
52
+ "Content-Type" => "application/json"
53
+ })
54
+
55
+ [ 200, headers, [ @swagger_document.to_json ] ]
50
56
  end
51
57
 
52
58
  def inspect
@@ -54,6 +60,19 @@ module Explicit::Documentation::Output
54
60
  end
55
61
 
56
62
  private
63
+ def respond_cors_preflight_request
64
+ [ 200, cors_access_control_headers, [] ]
65
+ end
66
+
67
+ def cors_access_control_headers
68
+ {
69
+ "Access-Control-Allow-Origin" => "*",
70
+ "Access-Control-Allow-Methods" => "GET, OPTIONS",
71
+ "Access-Control-Allow-Headers" => "Content-Type",
72
+ "Access-Control-Max-Age" => "86400"
73
+ }
74
+ end
75
+
57
76
  def get_base_url
58
77
  base_urls = builder.requests.map(&:get_base_url).uniq
59
78
  base_paths = builder.requests.map(&:get_base_path).uniq
@@ -8,8 +8,8 @@ module Explicit::Documentation::Output
8
8
  @builder = builder
9
9
  end
10
10
 
11
- def call(request)
12
- @html ||= render_documentation_page
11
+ def call(env)
12
+ @html ||= render_documentation_page(host: env["HTTP_HOST"])
13
13
 
14
14
  [200, {}, [@html]]
15
15
  end
@@ -21,10 +21,11 @@ module Explicit::Documentation::Output
21
21
  private
22
22
  Eval = ->(value) { value.respond_to?(:call) ? value.call : value }
23
23
 
24
- def render_documentation_page
24
+ def render_documentation_page(host:)
25
25
  Explicit::ApplicationController.render(
26
26
  partial: "explicit/documentation/page",
27
27
  locals: {
28
+ host:,
28
29
  url_helpers: @builder.rails_engine.routes.url_helpers,
29
30
  page_title: Eval[builder.get_page_title],
30
31
  company_logo_url: Eval[builder.get_company_logo_url],
@@ -17,7 +17,7 @@ module Explicit::Documentation
17
17
 
18
18
  engine.routes.draw do
19
19
  get "/", to: builder.webpage, as: :explicit_documentation_webpage
20
- get "/swagger", to: builder.swagger, as: :explicit_documentation_swagger
20
+ match "/swagger", to: builder.swagger, as: :explicit_documentation_swagger, via: [:get, :options]
21
21
  end
22
22
 
23
23
  engine
@@ -30,7 +30,7 @@ class Explicit::Type::BigDecimal < Explicit::Type
30
30
 
31
31
  concerning :Webpage do
32
32
  def summary
33
- "string"
33
+ "decimal string"
34
34
  end
35
35
 
36
36
  def partial
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Explicit
4
- VERSION = "0.2.14"
4
+ VERSION = "0.2.15"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explicit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Vasconcellos
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-06 00:00:00.000000000 Z
10
+ date: 2025-04-23 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -128,7 +127,6 @@ metadata:
128
127
  homepage_uri: https://github.com/luizpvas/explicit
129
128
  source_code_uri: https://github.com/luizpvas/explicit
130
129
  changelog_uri: https://github.com/luizpvas/explicit
131
- post_install_message:
132
130
  rdoc_options: []
133
131
  require_paths:
134
132
  - lib
@@ -143,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
141
  - !ruby/object:Gem::Version
144
142
  version: '0'
145
143
  requirements: []
146
- rubygems_version: 3.4.22
147
- signing_key:
144
+ rubygems_version: 3.6.2
148
145
  specification_version: 4
149
146
  summary: Explicit is a validation and documentation library for REST APIs
150
147
  test_files: []