/
api.go
132 lines (109 loc) · 3.31 KB
/
api.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package api
import (
"net/http"
. "github.com/swaggo/swag/testdata/simple/cross"
_ "github.com/swaggo/swag/testdata/simple/web"
)
// @Summary Add a new pet to the store
// @Description get string by ID
// @ID get-string-by-int
// @Accept json
// @Produce json
// @Param some_id path int true "Some ID" Format(int64)
// @Param some_id body web.Pet true "Some ID"
// @Success 200 {string} string "ok"
// @Failure 400 {object} web.APIError "We need ID!!"
// @Failure 404 {object} web.APIError "Can not find ID"
// @Router /testapi/get-string-by-int/{some_id} [get]
func GetStringByInt(w http.ResponseWriter, r *http.Request) {
_ = Cross{}
//write your code
}
// @Description get struct array by ID
// @ID get-struct-array-by-string
// @Accept json
// @Produce json
// @Param some_id path string true "Some ID"
// @Param category query int true "Category" Enums(1, 2, 3)
// @Param offset query int true "Offset" Minimum(0) default(0)
// @Param limit query int true "Limit" Maximum(50) default(10)
// @Param q query string true "q" Minlength(1) Maxlength(50) default("")
// @Success 200 {string} string "ok"
// @Failure 400 {object} web.APIError "We need ID!!"
// @Failure 404 {object} web.APIError "Can not find ID"
// @Security ApiKeyAuth
// @Security BasicAuth
// @Security OAuth2Application[write]
// @Security OAuth2Implicit[read, admin]
// @Security OAuth2AccessCode[read]
// @Security OAuth2Password[admin]
// @Security OAuth2Implicit[read, write] || Firebase
// @Router /testapi/get-struct-array-by-string/{some_id} [get]
func GetStructArrayByString(w http.ResponseWriter, r *http.Request) {
//write your code
}
// @Summary Upload file
// @Description Upload file
// @ID file.upload
// @Accept multipart/form-data
// @Produce json
// @Param file formData file true "this is a test file"
// @Success 200 {string} string "ok"
// @Failure 400 {object} web.APIError "We need ID!!"
// @Failure 401 {array} string
// @Failure 404 {object} web.APIError "Can not find ID"
// @Failure 403 {object} Cross "cross"
// @Router /file/upload [post]
func Upload(w http.ResponseWriter, r *http.Request) {
//write your code
}
// @Summary use Anonymous field
// @Success 200 {object} web.RevValue "ok"
// @Router /AnonymousField [get]
func AnonymousField() {
}
// @Summary use pet2
// @Success 200 {object} web.Pet2 "ok"
// @Router /Pet2 [get]
func Pet2() {
}
// @Summary Use IndirectRecursiveTest
// @Success 200 {object} web.IndirectRecursiveTest
// @Router /IndirectRecursiveTest [get]
func IndirectRecursiveTest() {
}
// @Summary Use Tags
// @Success 200 {object} web.Tags
// @Router /Tags [get]
func Tags() {
}
// @Summary Use CrossAlias
// @Success 200 {object} web.CrossAlias
// @Router /CrossAlias [get]
func CrossAlias() {
}
// @Summary Use AnonymousStructArray
// @Success 200 {object} web.AnonymousStructArray
// @Router /AnonymousStructArray [get]
func AnonymousStructArray() {
}
type Pet3 struct {
ID int `json:"id"`
}
// @Success 200 {object} web.Pet5a "ok"
// @Router /GetPet5a [options]
func GetPet5a() {
}
// @Success 200 {object} web.Pet5b "ok"
// @Router /GetPet5b [head]
func GetPet5b() {
}
// @Success 200 {object} web.Pet5c "ok"
// @Router /GetPet5c [patch]
func GetPet5c() {
}
type SwagReturn []map[string]string
// @Success 200 {object} api.SwagReturn "ok"
// @Router /GetPet6MapString [get]
func GetPet6MapString() {
}