apipie-postman 0.0.10 → 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/apipie-postman.rb +19 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeda7743bb6927b7777edb9342f3a275c86d77beec417611883399dcbf3e8d82
4
- data.tar.gz: 1d66263d27c38a1bc6dae8f2cfd6172e8830e3a2e70e1f05afac8627429aa5b3
3
+ metadata.gz: cb15fdaecb71ee97ad64d367620f122fc5ba847e682dfe5692c61b05d2fd8a98
4
+ data.tar.gz: 104174bf8f7dec3283fa1202e616c5d992d6496b8c6d99e3bb111e0293a0308f
5
5
  SHA512:
6
- metadata.gz: 437dbea53be02b6ebb000216890416c7296fba16817ef4b8d16028c3093e12327bcc86b9efc428c974daca6b16f280fad7df23e4991877377618c04f4118f0bb
7
- data.tar.gz: a65329f239dd995255aceebe4d2aa8933fd3f684c676e1b062aee3cd33e514aa039e73baa841210c795e4c3b5cb09f683278be7d1223e75c838a32a248f62b68
6
+ metadata.gz: e6c6ddb7271df9f1ff84f4f939cc86c7cd1365fc71b8ec505d183841b2d6ca7be309ebf25e93c26cc4e843b09fb50c0102422459bc41e1869e46e7bc8d7e12d7
7
+ data.tar.gz: 6e31ad3dd6ccea47efb91c80fb566a84434ea173a06bcc397e3914555b2b4536497274da284924e8598a2b1b7a5c6e5cd49791747ab2b7b91ed50e25faaff925
@@ -29,17 +29,19 @@ module ApipiePostman
29
29
  def self.generate_docs
30
30
  file = File.read('doc/apipie_examples.json')
31
31
  @docs = JSON.parse(file)
32
- docs_hashes = []
33
- endpoints_hashes = []
32
+ folder_hashes = []
34
33
 
35
- @docs.each_key do |key|
36
- docs_hashes << @docs[key]
37
- end
34
+ @docs = @docs.each_with_object({}) do |array, result|
35
+ key = array[0].to_s.split('#')[0]
36
+ (result[key] ||= []).concat(array[1])
37
+ end.transform_values(&:flatten)
38
38
 
39
- docs_hashes.each do |doc_hash|
40
- doc_hash.each do |endpoint|
41
- endpoints_hashes << create_endpoint_hash(endpoint, endpoint['request_data'] || {})
39
+ @docs.each_key do |key|
40
+ key_endpoint_hashes = []
41
+ @docs[key].each do |endpoint|
42
+ key_endpoint_hashes << create_endpoint_hash(endpoint, endpoint['request_data'] || {})
42
43
  end
44
+ folder_hashes << create_folder(key, key_endpoint_hashes)
43
45
  end
44
46
 
45
47
  body = {
@@ -49,7 +51,7 @@ module ApipiePostman
49
51
  description: 'Test description',
50
52
  schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json'
51
53
  },
52
- item: endpoints_hashes
54
+ item: folder_hashes
53
55
  }
54
56
  }.to_json
55
57
 
@@ -90,4 +92,12 @@ module ApipiePostman
90
92
  response: []
91
93
  }
92
94
  end
95
+
96
+ def self.create_folder(key, item_hashes)
97
+ {
98
+ name: key,
99
+ description: key,
100
+ item: item_hashes
101
+ }
102
+ end
93
103
  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.10
4
+ version: 1.0.0
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-10-14 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday