rspec-autoswagger 0.4.1 → 0.5.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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76c568faf41372d1f2c47bed9f0305ebdfecae2b
|
4
|
+
data.tar.gz: ab707fe34a2011e9671d0c2479091d5490bf84f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1290645d60f8b15c321228b1b3653a533d6d0904bf18eea60bd221c2b11a14eea3f94979cdaf6bc36dc530f079009199a1456e6f5c9e3a5d3c2b854eb64f97
|
7
|
+
data.tar.gz: 8130e944992f5ec08e3621a02e361f4642300dc8dc47d7b181c935095d93b038c516fce21056c9c16c68fa189a0faee3d492a9db25a80b3a2364ca0583220e38
|
data/lib/rspec/autoswagger.rb
CHANGED
@@ -1,27 +1,51 @@
|
|
1
1
|
require 'rspec/autoswagger/parts/path'
|
2
2
|
require 'rspec/autoswagger/parts/info'
|
3
3
|
require 'rspec/autoswagger/parts/definition'
|
4
|
+
require 'rspec/autoswagger/util'
|
4
5
|
|
5
6
|
module Rspec
|
6
7
|
module Autoswagger
|
7
8
|
class DocPart
|
8
9
|
|
9
|
-
attr_reader :rspec_core_obj, :example
|
10
|
+
attr_reader :rspec_core_obj, :example, :request
|
10
11
|
|
11
12
|
def initialize(rspec_core_obj, example)
|
12
13
|
@rspec_core_obj = rspec_core_obj
|
14
|
+
@request = rspec_core_obj.request
|
13
15
|
@example = example
|
14
16
|
end
|
15
17
|
|
16
18
|
def response_name
|
17
19
|
status = rspec_core_obj.response.status.to_s
|
18
20
|
if status == '200'
|
19
|
-
example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
21
|
+
path = example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
22
|
+
path = if path.blank?
|
23
|
+
path = request.path.gsub(Rspec::Autoswagger::API_BASE_PATH, '')
|
24
|
+
get_converted_path(path)
|
25
|
+
end
|
26
|
+
path.gsub(/\/|:/, '').camelize
|
20
27
|
else
|
21
|
-
example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
28
|
+
path = example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
29
|
+
path = if path.blank?
|
30
|
+
path = request.path.gsub(Rspec::Autoswagger::API_BASE_PATH, '')
|
31
|
+
get_converted_path(path)
|
32
|
+
end
|
33
|
+
path.gsub(/\/|:/, '').camelize + '_' + status
|
22
34
|
end
|
23
35
|
end
|
24
36
|
|
37
|
+
def get_converted_path(path)
|
38
|
+
path.split("/").map do |path_element|
|
39
|
+
if Util.detect_uuid(path_element)
|
40
|
+
":id"
|
41
|
+
elsif Util.detect_uuid(path_element)
|
42
|
+
":id"
|
43
|
+
else
|
44
|
+
path_element
|
45
|
+
end
|
46
|
+
end.join("/")
|
47
|
+
end
|
48
|
+
|
25
49
|
def create_path
|
26
50
|
path = Parts::Path.new(rspec_core_obj, example, response_name)
|
27
51
|
path.generate_hash
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/autoswagger/util'
|
2
|
+
|
1
3
|
module Rspec
|
2
4
|
module Autoswagger
|
3
5
|
module Parts
|
@@ -10,7 +12,6 @@ module Rspec
|
|
10
12
|
begin
|
11
13
|
@description = rspec_core_obj.description
|
12
14
|
rescue RSpec::Core::ExampleGroup::WrongScopeError
|
13
|
-
puts "[AUTOSWAGGER WARNING] please write description"
|
14
15
|
@description = ''
|
15
16
|
end
|
16
17
|
@example = example
|
@@ -19,7 +20,24 @@ module Rspec
|
|
19
20
|
|
20
21
|
def path
|
21
22
|
path = example.full_description[%r<(GET|POST|PATCH|PUT|DELETE) ([^ ]+)>, 2]
|
22
|
-
path.
|
23
|
+
if path.blank?
|
24
|
+
path = request.path.gsub(Rspec::Autoswagger::API_BASE_PATH, '')
|
25
|
+
get_converted_path(path)
|
26
|
+
else
|
27
|
+
path.split("/").map { |name| name.include?(":") ? "{" + name.gsub(":", "") + "}" : name }.join("/")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_converted_path(path)
|
32
|
+
path.split("/").map do |path_element|
|
33
|
+
if Util.detect_uuid(path_element)
|
34
|
+
"{id}"
|
35
|
+
elsif Util.detect_uuid(path_element)
|
36
|
+
"{id}"
|
37
|
+
else
|
38
|
+
path_element
|
39
|
+
end
|
40
|
+
end.join("/")
|
23
41
|
end
|
24
42
|
|
25
43
|
def tags
|
data/rspec-autoswagger.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_dependency "swagger_model", '0.4.
|
31
|
+
spec.add_dependency "swagger_model", '0.4.8'
|
32
32
|
spec.add_dependency "rspec"
|
33
33
|
spec.add_dependency "activesupport"
|
34
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-autoswagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joooee0000
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: swagger_model
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.4.
|
19
|
+
version: 0.4.8
|
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: 0.4.
|
26
|
+
version: 0.4.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/rspec/autoswagger/parts/info.rb
|
105
105
|
- lib/rspec/autoswagger/parts/path.rb
|
106
106
|
- lib/rspec/autoswagger/rspec.rb
|
107
|
+
- lib/rspec/autoswagger/util.rb
|
107
108
|
- lib/rspec/autoswagger/version.rb
|
108
109
|
- rspec-autoswagger.gemspec
|
109
110
|
homepage: https://github.com/joooee0000/rspec-autoswagger
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Rspec extension to auto generate swagger/openapi specification
|