swagalicious 0.4.4 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d1f1a314f7e3c84ef64184ba490e5d90971fc56213f74829f5af6f0fc6b0274
4
- data.tar.gz: a6e07a214f9e574c8151ea7c459d0445790ed79f1a9b6f9dc9958bab9aef9406
3
+ metadata.gz: 356ef7d1c57b5d2c0887ef48741926c1d15799b0dee6ec2f44c447ccad909c56
4
+ data.tar.gz: 3daa87a8d3b13e7b35d688b6620bf050f07eb208938a1fd257613a8bca259714
5
5
  SHA512:
6
- metadata.gz: 87bc78e516ccf7ce48eb88b3aaf8045415dd147e6de880b422366fd679b86eac12fb0df34b97358578da75129e49e2dd08285297449a3f26ea85eee503c18098
7
- data.tar.gz: 4b083368ef0dc6fb3cb90bb8fd39dbdbde0731de0e41df4583b188822b9387df4c53620941f91a3173b4a54e56fd99f8ba581f0b3de791672d729ed519f00e8c
6
+ metadata.gz: 3a9e321d4f883d71c12a05212ae97b7d55b1c403d69820c8c58236382e5abf4d1f869e3aba13dba3fe3a8134d06264145f6523b89a27f7cc4a18bb4539bb86a1
7
+ data.tar.gz: 80d3b8950565c86d82f4437eac5d9ed022913f0b3df4c8f2e32d1edc3ce57ea41be2925d3b1f829952e6fb93dcc9de63685d88a24c1d327a0a3228bd715dc420
data/.gitignore CHANGED
@@ -7,5 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ *.gem
11
+
10
12
  # rspec failure tracking
11
13
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,70 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swagalicious (0.4.3)
5
- faraday (~> 1.3.0)
6
- json-schema (~> 2.8.1)
4
+ swagalicious (0.4.6)
5
+ faraday (~> 2.0)
6
+ faraday-rack
7
+ json-schema
7
8
  oj (~> 3.11.0)
8
- rspec (~> 3.10.0)
9
+ rspec (~> 3)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- activesupport (6.1.1)
14
+ activesupport (6.1.6)
14
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
16
  i18n (>= 1.6, < 2)
16
17
  minitest (>= 5.1)
17
18
  tzinfo (~> 2.0)
18
19
  zeitwerk (~> 2.3)
19
- addressable (2.7.0)
20
+ addressable (2.8.0)
20
21
  public_suffix (>= 2.0.2, < 5.0)
21
22
  byebug (11.1.3)
22
23
  coderay (1.1.3)
23
- concurrent-ruby (1.1.8)
24
- diff-lcs (1.4.4)
24
+ concurrent-ruby (1.1.10)
25
+ diff-lcs (1.5.0)
25
26
  factory_bot (6.1.0)
26
27
  activesupport (>= 5.0.0)
27
- faraday (1.3.0)
28
- faraday-net_http (~> 1.0)
29
- multipart-post (>= 1.2, < 3)
30
- ruby2_keywords
31
- faraday-net_http (1.0.1)
32
- i18n (1.8.7)
28
+ faraday (2.3.0)
29
+ faraday-net_http (~> 2.0)
30
+ ruby2_keywords (>= 0.0.4)
31
+ faraday-net_http (2.0.3)
32
+ faraday-rack (2.0.0)
33
+ faraday (~> 2.0)
34
+ i18n (1.10.0)
33
35
  concurrent-ruby (~> 1.0)
34
- json-schema (2.8.1)
35
- addressable (>= 2.4)
36
+ json-schema (3.0.0)
37
+ addressable (>= 2.8)
36
38
  method_source (1.0.0)
37
- minitest (5.14.3)
38
- multipart-post (2.1.1)
39
- oj (3.11.3)
39
+ minitest (5.16.1)
40
+ oj (3.11.8)
40
41
  pry (0.13.1)
41
42
  coderay (~> 1.1)
42
43
  method_source (~> 1.0)
43
44
  pry-byebug (3.9.0)
44
45
  byebug (~> 11.0)
45
46
  pry (~> 0.13.0)
46
- public_suffix (4.0.6)
47
- rack (2.2.3)
47
+ public_suffix (4.0.7)
48
+ rack (2.2.3.1)
48
49
  rack-test (1.1.0)
49
50
  rack (>= 1.0, < 3)
50
51
  rake (12.3.3)
51
- rspec (3.10.0)
52
- rspec-core (~> 3.10.0)
53
- rspec-expectations (~> 3.10.0)
54
- rspec-mocks (~> 3.10.0)
55
- rspec-core (3.10.1)
56
- rspec-support (~> 3.10.0)
57
- rspec-expectations (3.10.1)
52
+ rspec (3.11.0)
53
+ rspec-core (~> 3.11.0)
54
+ rspec-expectations (~> 3.11.0)
55
+ rspec-mocks (~> 3.11.0)
56
+ rspec-core (3.11.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-expectations (3.11.0)
58
59
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.10.0)
60
- rspec-mocks (3.10.1)
60
+ rspec-support (~> 3.11.0)
61
+ rspec-mocks (3.11.1)
61
62
  diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.10.0)
63
- rspec-support (3.10.1)
64
- ruby2_keywords (0.0.4)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-support (3.11.0)
65
+ ruby2_keywords (0.0.5)
65
66
  tzinfo (2.0.4)
66
67
  concurrent-ruby (~> 1.0)
67
- zeitwerk (2.4.2)
68
+ zeitwerk (2.6.0)
68
69
 
69
70
  PLATFORMS
70
71
  ruby
@@ -78,4 +79,4 @@ DEPENDENCIES
78
79
  swagalicious!
79
80
 
80
81
  BUNDLED WITH
81
- 2.2.16
82
+ 2.2.31
@@ -1,5 +1,5 @@
1
1
  require "faraday"
2
- require "faraday/adapter/rack"
2
+ require "faraday/rack"
3
3
  require "rack"
4
4
  require "oj"
5
5
 
@@ -20,7 +20,7 @@ class Swagalicious
20
20
  end
21
21
 
22
22
  def app
23
- @app ||= Rack::Builder.parse_file("config.ru").first
23
+ @app ||= defined?(Rails) ? Rails.application : Rack::Builder.parse_file("config.ru").first
24
24
  end
25
25
 
26
26
  def client
@@ -30,15 +30,17 @@ class Swagalicious
30
30
  end
31
31
 
32
32
  def submit_request(metadata, mocked: false, mock_name: nil)
33
- request = RequestFactory.new.build_request(metadata, self)
33
+ request = RequestFactory.new.build_request(metadata, self)
34
+ uri = URI.parse(request[:path])
35
+ uri.path = uri.path.gsub("//", "/")
34
36
 
35
37
  response = if mocked
36
- file_name = File.basename(mock_name || URI.parse(request[:path]).path)
38
+ file_name = File.basename(mock_name || path)
37
39
 
38
40
  MockResponse.new(file_name)
39
41
  else
40
42
  client.public_send(request[:verb]) do |req|
41
- req.url request[:path].gsub("//", "/")
43
+ req.url uri.to_s
42
44
  req.headers = request[:headers]
43
45
  req.body = request[:payload]
44
46
  end
@@ -68,7 +70,7 @@ class Swagalicious
68
70
  metadata[:response][:requestBody][:content][mime_type][:examples][full_title][:value] = Oj.load(request[:payload]).dup
69
71
  end
70
72
 
71
- metadata[:response][:examples][mime_type] ||= {}
73
+ metadata[:response][:examples][mime_type] ||= {}
72
74
  metadata[:response][:examples][mime_type][full_title] = @body
73
75
  end
74
76
 
@@ -12,7 +12,7 @@ class Swagalicious
12
12
 
13
13
  class ExtendedTypeAttribute < JSON::Schema::TypeV4Attribute
14
14
  def self.validate(current_schema, data, fragments, processor, validator, options={})
15
- return if data.nil? && current_schema.schema["null"] == true
15
+ return if data.nil? && (current_schema.schema["null"] == true || current_schema.schema["nullable"] == true)
16
16
  super
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  class Swagalicious
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.7"
3
3
  end
data/lib/swagalicious.rb CHANGED
@@ -2,6 +2,11 @@ require "rspec/core"
2
2
 
3
3
  require_relative "./swagalicious/version"
4
4
 
5
+ begin
6
+ require "rspec/rails"
7
+ rescue nil
8
+ end
9
+
5
10
  class Swagalicious
6
11
  class Error < StandardError; end
7
12
 
@@ -24,6 +29,11 @@ class Swagalicious
24
29
  c.add_setting :swagger_root
25
30
  c.add_setting :swagger_docs
26
31
  c.add_setting :swagger_dry_run
32
+
33
+ if defined?(Rails) && defined?(RSpec::Rails)
34
+ c.include RSpec::Rails::RequestExampleGroup, type: :doc
35
+ end
36
+
27
37
  c.extend Swagalicious::ExampleGroupHelpers, type: :doc
28
38
  c.include Swagalicious::ExampleHelpers, type: :doc
29
39
  end
data/swagalicious.gemspec CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  spec.name = "swagalicious"
5
5
  spec.version = Swagalicious::VERSION
6
6
  spec.authors = ["Eugene Howe"]
7
- spec.email = ["eugene@xtreme-computers.net"]
7
+ spec.email = ["eugene.howe@protonmail.com"]
8
8
 
9
9
  spec.summary = %q{RSwag without Rails}
10
10
  spec.description = %q{This gem is almost a straight copy and paste of https://github.com/rswag/rswag/tree/master/rswag-specs with the Rails specific code stripped out so it can be used in Rack applications that don't use Rails.}
@@ -24,10 +24,11 @@ Gem::Specification.new do |spec|
24
24
  end
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency "faraday", "~> 1.3.0"
28
- spec.add_dependency "json-schema", "~> 2.8.1"
29
- spec.add_dependency "oj", "~> 3.11.0"
30
- spec.add_dependency "rspec", "~> 3.10.0"
27
+ spec.add_dependency "faraday", "~> 2.0"
28
+ spec.add_dependency "faraday-rack"
29
+ spec.add_dependency "json-schema"
30
+ spec.add_dependency "oj", "~> 3.11.0"
31
+ spec.add_dependency "rspec", "~> 3"
31
32
 
32
33
  spec.add_development_dependency "factory_bot", "~> 6.1.0"
33
34
  spec.add_development_dependency "pry-byebug", "~> 3.9.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagalicious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Howe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-23 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: json-schema
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 2.8.1
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 2.8.1
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: oj
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +72,14 @@ dependencies:
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 3.10.0
75
+ version: '3'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 3.10.0
82
+ version: '3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: factory_bot
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +126,7 @@ description: This gem is almost a straight copy and paste of https://github.com/
112
126
  with the Rails specific code stripped out so it can be used in Rack applications
113
127
  that don't use Rails.
114
128
  email:
115
- - eugene@xtreme-computers.net
129
+ - eugene.howe@protonmail.com
116
130
  executables: []
117
131
  extensions: []
118
132
  extra_rdoc_files: []