apipie-postman 0.0.5 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apipie-postman.rb +31 -31
- metadata +29 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dfa2e61723b3482b30e8c84f3959337683b0ffce10f01503b264c6f46829b89
|
4
|
+
data.tar.gz: b7f56bb490b953d318b999d34c3c19336ea0635a1689ca90479ae9d682291b28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f46c44589d2af56f51e09cd31a06a012c3c15ac7bb773fa0f5502a9f5f0b40cf2051e3c238eb54f12b865f4983274479db9c11edfe7da40f0fa338dfabf62712
|
7
|
+
data.tar.gz: 97466a90c239c70be1a844e320af7f27e16f602eda28be93887786432beee804969b43a81de6237b7b2d55df27eb614b69b11c73b8cb32c5ec1d078e36e376be
|
data/lib/apipie-postman.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'json'
|
4
4
|
require 'faraday'
|
5
5
|
|
6
|
-
# General module for gem
|
7
6
|
module ApipiePostman
|
8
7
|
class << self
|
9
8
|
attr_accessor :configuration
|
@@ -39,26 +38,7 @@ module ApipiePostman
|
|
39
38
|
|
40
39
|
docs_hashes.each do |doc_hash|
|
41
40
|
doc_hash.each do |endpoint|
|
42
|
-
|
43
|
-
{}
|
44
|
-
else
|
45
|
-
endpoint['request_data']
|
46
|
-
end
|
47
|
-
|
48
|
-
endpoints_hashes << {
|
49
|
-
name: endpoint['title'],
|
50
|
-
request: {
|
51
|
-
url: "#{self.configuration.base_url}#{endpoint['path']}",
|
52
|
-
method: endpoint['verb'],
|
53
|
-
header: [],
|
54
|
-
body: {
|
55
|
-
mode: 'raw',
|
56
|
-
raw: req_body.to_json
|
57
|
-
},
|
58
|
-
description: endpoint['title']
|
59
|
-
},
|
60
|
-
response: []
|
61
|
-
}
|
41
|
+
endpoints_hashes << create_endpoint_hash(endpoint, endpoint['request_data'] || {})
|
62
42
|
end
|
63
43
|
end
|
64
44
|
|
@@ -72,22 +52,42 @@ module ApipiePostman
|
|
72
52
|
item: endpoints_hashes
|
73
53
|
}
|
74
54
|
}.to_json
|
55
|
+
|
75
56
|
headers = {
|
76
57
|
'X-Api-Key': self.configuration.postman_api_key,
|
77
58
|
'Content-Type': 'application/json'
|
78
59
|
}
|
79
60
|
|
80
|
-
|
61
|
+
collection_uid = check_collection_uid_by_name(headers)
|
62
|
+
|
63
|
+
if collection_uid.nil?
|
64
|
+
Faraday.public_send(:post, 'https://api.getpostman.com/collections/', body, headers)
|
65
|
+
else
|
66
|
+
Faraday.public_send(:put, "https://api.getpostman.com/collections/#{collection_uid['uid']}", body, headers)
|
67
|
+
end
|
68
|
+
end
|
81
69
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
70
|
+
def self.check_collection_uid_by_name(headers)
|
71
|
+
response = Faraday.public_send(:get, 'https://api.getpostman.com/collections/', {}, headers)
|
72
|
+
JSON.parse(response.body)['collections'].select do |col|
|
73
|
+
col['name'] == self.configuration.postman_collection_name
|
74
|
+
end.last
|
75
|
+
end
|
86
76
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
77
|
+
def self.create_endpoint_hash(endpoint, req_body)
|
78
|
+
{
|
79
|
+
name: endpoint['title'] == 'Default' ? "#{endpoint['verb']} #{endpoint['path']}" : endpoint['title'],
|
80
|
+
request: {
|
81
|
+
url: "#{self.configuration.base_url}#{endpoint['path']}",
|
82
|
+
method: endpoint['verb'],
|
83
|
+
header: [],
|
84
|
+
body: {
|
85
|
+
mode: 'raw',
|
86
|
+
raw: req_body.to_json
|
87
|
+
},
|
88
|
+
description: endpoint['title']
|
89
|
+
},
|
90
|
+
response: []
|
91
|
+
}
|
92
92
|
end
|
93
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-postman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Motogna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.0.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.0.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: pry
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,8 +58,28 @@ dependencies:
|
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '3.10'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.22'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.22.1
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.22'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.22.1
|
55
81
|
description: Use 'bundle exec apipie-postman' and 'rake apipie_postman' to generate
|
56
|
-
the docs!
|
82
|
+
the docs!
|
57
83
|
email: vmotogna@gmail.com
|
58
84
|
executables:
|
59
85
|
- apipie-postman
|