-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc_postman.go
79 lines (66 loc) · 1.87 KB
/
doc_postman.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package pick
import (
"encoding/json"
"log"
)
// TODO
type PMHeader struct {
Key string `json:"key"`
Value string `json:"value"`
Type string `json:"type"`
Disable bool `json:"disable"`
}
type PMBody struct {
Mode string `json:"mode"`
Raw string `json:"raw"`
}
type PMRequest struct {
Method string `json:"method"`
Header []PMHeader `json:"header"`
Body PMBody `json:"body"`
Description string `json:"description"`
URL PMUrl `json:"url"`
}
type PMUrl struct {
Raw string `json:"raw"`
Protocol string `json:"protocol"`
Host []string `json:"host"`
Path []string `json:"path"`
Query []PMQuery `json:"query"`
}
type PMProtocolProfileBehavior struct {
DisableBodyPruning bool `json:"disableBodyPruning"`
}
type PMApi struct {
Name string `json:"name"`
ProtocolProfileBehavior PMProtocolProfileBehavior `json:"protocolProfileBehavior"`
Request PMRequest `json:"request"`
Response []interface{} `json:"response"`
}
type PMCategory struct {
Name string `json:"name"`
ProtocolProfileBehavior PMProtocolProfileBehavior `json:"protocolProfileBehavior"`
Items []PMApi `json:"item"`
}
type PMInfo struct {
PostManId string `json:"_postman_id"`
Name string `json:"name"`
Schema string `json:"schema"`
}
type PMFile struct {
Info PMInfo `json:"info"`
Items []PMCategory `json:"item"`
}
type PMQuery struct {
Key string `json:"key"`
Value string `json:"value"`
}
func genPostman() string {
pObj := PMFile{}
pObj.Info.Schema = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
ret, err := json.MarshalIndent(pObj, "", " ")
if err != nil {
log.Println(err.Error())
}
return string(ret)
}