postman_doc_generator 0.1.1 → 0.1.6
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 +4 -4
- data/.gitignore +1 -0
- data/config/postman_doc_generator.yml +14 -0
- data/lib/postman_doc_generator.rb +10 -9
- data/postman_doc_generator.gemspec +18 -0
- data/sample/doc.json +9 -0
- data/sample/request.json +25 -0
- data/sample/response.json +29 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c7b3dbedfed56bd2f1fab1f31ac1a50d55519d480331f10eaaee6ec94bf513
|
4
|
+
data.tar.gz: 0d0cc052afbe3c4e1bfb651ed7c58e80630cb53bbec7df2e614fc96794099ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40650c1683be126d8b214483ca9be120a1b1d009284ab0a4ca90d658a5771b6ac2a0ac7a892422c87f3f742e8bc5b2d64d804470e288eee735bc459bff6e6e10
|
7
|
+
data.tar.gz: '029f5e5cef8559630112cb0186faa24f669932140e308b3ffa75d097bc062c057380eb77a2fcd458467cb6463966445ddae86bb5daf7b5fa4dfc4163ea8eeb8c'
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
@@ -0,0 +1,14 @@
|
|
1
|
+
development: &development
|
2
|
+
postman_dir: tmp/postman
|
3
|
+
postman_id: defalt_postman_id
|
4
|
+
project_name: Default Project
|
5
|
+
project_host: "{{default_host}}"
|
6
|
+
server_host: "preparing: https://preparing4.kdanmobile.com:3012\n* production: https://store-center.kdanmobile.com (working)"
|
7
|
+
api_doc_name: api_doc
|
8
|
+
api_doc_link: api_doc_link
|
9
|
+
|
10
|
+
test:
|
11
|
+
<<: *development
|
12
|
+
|
13
|
+
production:
|
14
|
+
<<: *development
|
@@ -4,13 +4,15 @@ require 'fileutils'
|
|
4
4
|
class PostmanDocGenerator
|
5
5
|
attr_accessor :result, :error
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
class << self
|
8
|
+
def start(http_method, path, controller, response)
|
9
|
+
generator = new(http_method, path, controller, response)
|
10
|
+
generator.call
|
11
|
+
rescue => e
|
12
|
+
generator.error = e
|
13
|
+
ensure
|
14
|
+
generator
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def initialize(http_method, path, controller, response)
|
@@ -19,7 +21,6 @@ class PostmanDocGenerator
|
|
19
21
|
@path = path
|
20
22
|
@controller = controller
|
21
23
|
@response = response
|
22
|
-
@file_path = file_path
|
23
24
|
end
|
24
25
|
|
25
26
|
def call
|
@@ -47,7 +48,7 @@ class PostmanDocGenerator
|
|
47
48
|
@res_status = @response.status
|
48
49
|
@res_body = @response.body.present? ? JSON.parse(@response.body) : {}
|
49
50
|
data = File.read(@file_path) if File.exist?(@file_path)
|
50
|
-
@postman_data = data.blank? ? JSON.parse(File.read("#{@sample_dir}/doc.json") % @config) : JSON.parse(data)
|
51
|
+
@postman_data = data.blank? ? JSON.parse(File.read("#{@sample_dir}/doc.json") % @config.transform_keys(&:to_sym)) : JSON.parse(data)
|
51
52
|
end
|
52
53
|
|
53
54
|
def setup_postman_json
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'postman_doc_generator'
|
3
|
+
s.version = '0.1.6'
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.summary = 'Generate Postman Doc Json After Run Rspec'
|
6
|
+
s.description = 'A Json API Doc Generator of Postman'
|
7
|
+
s.authors = ['JiaRou']
|
8
|
+
s.email = 'laura34963@kdanmobile.com'
|
9
|
+
s.homepage = 'https://github.com/laura34963/postman_doc_generator'
|
10
|
+
s.license = 'MIT'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.extra_rdoc_files = [ 'README.md' ]
|
14
|
+
s.rdoc_options = ['--charset=UTF-8']
|
15
|
+
|
16
|
+
s.required_ruby_version = '>= 2.6.1'
|
17
|
+
s.add_development_dependency 'rspec', ['~> 3.0']
|
18
|
+
end
|
data/sample/doc.json
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
{
|
2
|
+
"info": {
|
3
|
+
"_postman_id": "%{postman_id}",
|
4
|
+
"name": "%{project_name}",
|
5
|
+
"description": "%{project_name}\n\n# Enviorments\n\n* %{server_host}\n\n\n### API Document\n[%{api_doc_name}](%{api_doc_link})",
|
6
|
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
7
|
+
},
|
8
|
+
"item": []
|
9
|
+
}
|
data/sample/request.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "",
|
3
|
+
"request": {
|
4
|
+
"method": "",
|
5
|
+
"header": [],
|
6
|
+
"body": {
|
7
|
+
"mode": "raw",
|
8
|
+
"raw": "",
|
9
|
+
"options": {
|
10
|
+
"raw": {
|
11
|
+
"language": "json"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"url": {
|
16
|
+
"raw": "",
|
17
|
+
"host": [
|
18
|
+
""
|
19
|
+
],
|
20
|
+
"path": []
|
21
|
+
},
|
22
|
+
"description": ""
|
23
|
+
},
|
24
|
+
"response": []
|
25
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"name": "",
|
3
|
+
"originalRequest": {
|
4
|
+
"method": "",
|
5
|
+
"header": [],
|
6
|
+
"body": {
|
7
|
+
"mode": "raw",
|
8
|
+
"raw": "",
|
9
|
+
"options": {
|
10
|
+
"raw": {
|
11
|
+
"language": "json"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"url": {
|
16
|
+
"raw": "",
|
17
|
+
"host": [
|
18
|
+
""
|
19
|
+
],
|
20
|
+
"path": []
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"status": "",
|
24
|
+
"code": 200,
|
25
|
+
"_postman_previewlanguage": "json",
|
26
|
+
"header": [],
|
27
|
+
"cookie": [],
|
28
|
+
"body": ""
|
29
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postman_doc_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JiaRou
|
@@ -31,8 +31,14 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- README.md
|
33
33
|
files:
|
34
|
+
- ".gitignore"
|
34
35
|
- README.md
|
36
|
+
- config/postman_doc_generator.yml
|
35
37
|
- lib/postman_doc_generator.rb
|
38
|
+
- postman_doc_generator.gemspec
|
39
|
+
- sample/doc.json
|
40
|
+
- sample/request.json
|
41
|
+
- sample/response.json
|
36
42
|
homepage: https://github.com/laura34963/postman_doc_generator
|
37
43
|
licenses:
|
38
44
|
- MIT
|
@@ -53,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
55
61
|
requirements: []
|
56
|
-
rubygems_version: 3.
|
62
|
+
rubygems_version: 3.1.4
|
57
63
|
signing_key:
|
58
64
|
specification_version: 4
|
59
65
|
summary: Generate Postman Doc Json After Run Rspec
|