swaggard 4.1.0 → 4.1.1

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: 28d2106f9e0d61087b74c97d99c4e3e6c848b9bee4afa7fb6a828db0466cb134
4
- data.tar.gz: 668252d84bbdc87a23ed4191cc5baae2c2c7dfbe2b06cb794d8a7fe947cbf70c
3
+ metadata.gz: 0f81d2b18d49097affa50030384f9ba3ca7a53ddd363952f2496bf77496eee5d
4
+ data.tar.gz: fc112e57ff31fcf3a699543054c97d4a3204113acfca9014c9133d0a5acd5ee3
5
5
  SHA512:
6
- metadata.gz: fbc1a171bbb0b3eaf2d285e4eebb9e3b2d76196745865afb727de157be519be9604d12af0745c9d2a7d73a5b52f0916230e98372bbc94af67159552cf72302dc
7
- data.tar.gz: a648d45fc2cffc78502e548ccafcfbc2ff4ece0bccee7a75b3d4827cffab98d1672304bca5d63bcd1b94f1f0dc4d7a8cd373faea5adf61ca356f4f553928493c
6
+ metadata.gz: 503363ed15e0b78f38e56cee37a40c5ff06810be7b7cfd6886aa1fa6eedd9dd2724e00f3ae4f756c03995ef832e16ab146fd4bd9e700a7c8de57e0ab8fbcc846
7
+ data.tar.gz: 3459ce52d39b49c4d12036a4cd1fa01f019b08ba5572d66cd619909369487e9109a1cdd84caf223c7ca93df01f2e03636dd18ade95bf7a8cd544b77c3128170d
@@ -66,7 +66,9 @@ module Swaggard
66
66
  def format_path(path)
67
67
  return path unless Swaggard.configuration.exclude_base_path_from_paths
68
68
 
69
- path.gsub(Swaggard.configuration.api_base_path, '')
69
+ base_path = Swaggard.configuration.api_base_path
70
+
71
+ path.sub(/\A#{Regexp.escape(base_path)}/, '')
70
72
  end
71
73
 
72
74
  def build_components
@@ -1,3 +1,3 @@
1
1
  module Swaggard
2
- VERSION = '4.1.0'
2
+ VERSION = '4.1.1'
3
3
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Swaggard::ApiDefinition do
4
+ describe '#format_path' do
5
+ subject(:formatted) { described_class.new.send(:format_path, path) }
6
+
7
+ let(:original_base_path) { Swaggard.configuration.api_base_path }
8
+ let(:original_exclude) { Swaggard.configuration.exclude_base_path_from_paths }
9
+
10
+ before do
11
+ original_base_path
12
+ original_exclude
13
+ Swaggard.configuration.api_base_path = '/api'
14
+ Swaggard.configuration.exclude_base_path_from_paths = true
15
+ end
16
+
17
+ after do
18
+ Swaggard.configuration.api_base_path = original_base_path
19
+ Swaggard.configuration.exclude_base_path_from_paths = original_exclude
20
+ end
21
+
22
+ context 'when the base path also appears inside a later path segment' do
23
+ let(:path) { '/api/partner/api_keys' }
24
+
25
+ it 'strips only the leading base path, not every occurrence' do
26
+ expect(formatted).to eq('/partner/api_keys')
27
+ end
28
+ end
29
+
30
+ context 'with a path that only contains the leading base path' do
31
+ let(:path) { '/api/partner/products' }
32
+
33
+ it 'strips the leading base path' do
34
+ expect(formatted).to eq('/partner/products')
35
+ end
36
+ end
37
+
38
+ context 'when exclude_base_path_from_paths is disabled' do
39
+ let(:path) { '/api/partner/api_keys' }
40
+
41
+ before { Swaggard.configuration.exclude_base_path_from_paths = false }
42
+
43
+ it 'returns the path unchanged' do
44
+ expect(formatted).to eq('/api/partner/api_keys')
45
+ end
46
+ end
47
+ end
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swaggard
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Gomez
@@ -162,6 +162,7 @@ files:
162
162
  - spec/integration/openapi_spec.rb
163
163
  - spec/integration/swaggard_spec.rb
164
164
  - spec/spec_helper.rb
165
+ - spec/swaggard/api_definition_spec.rb
165
166
  - spec/swaggard/parsers/property_spec.rb
166
167
  - spec/swaggard/swagger/definition_spec.rb
167
168
  - spec/swaggard/swagger/parameters/body_spec.rb
@@ -203,6 +204,7 @@ test_files:
203
204
  - spec/integration/openapi_spec.rb
204
205
  - spec/integration/swaggard_spec.rb
205
206
  - spec/spec_helper.rb
207
+ - spec/swaggard/api_definition_spec.rb
206
208
  - spec/swaggard/parsers/property_spec.rb
207
209
  - spec/swaggard/swagger/definition_spec.rb
208
210
  - spec/swaggard/swagger/parameters/body_spec.rb