Skip to content

Commit f0062fa

Browse files
committed
regenerate swagger doc
1 parent fcefaba commit f0062fa

File tree

10 files changed

+1178
-27
lines changed

10 files changed

+1178
-27
lines changed

api/doc.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package api
2+
3+
import (
4+
"embed"
5+
"io/fs"
6+
"net/http"
7+
)
8+
9+
//go:embed doc.swagger.json
10+
var doc embed.FS
11+
12+
func OpenAPIHandler() http.Handler {
13+
// Use subdirectory in embedded files
14+
subFS, err := fs.Sub(doc, ".")
15+
if err != nil {
16+
panic("couldn't create sub filesystem: " + err.Error())
17+
}
18+
return http.FileServer(http.FS(subFS))
19+
}

api/doc.swagger.json

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "helloworld demo api definition",
5+
"version": "1.0",
6+
"contact": {
7+
"name": "douyu",
8+
"url": "https://github.com/douyu/proto"
9+
}
10+
},
11+
"tags": [
12+
{
13+
"name": "helloworld.v1.GreeterService"
14+
},
15+
{
16+
"name": "Project 001",
17+
"description": "This is how we do it.",
18+
"externalDocs": {
19+
"description": "Find out more",
20+
"url": "https://github.com/douyu/proto"
21+
}
22+
}
23+
],
24+
"consumes": [
25+
"application/x-www-form-urlencoded"
26+
],
27+
"produces": [
28+
"application/json"
29+
],
30+
"paths": {
31+
"/v1/helloworld.Greeter/SayHello": {
32+
"post": {
33+
"summary": "Sends a hello greeting",
34+
"operationId": "GreeterService_SayHello",
35+
"responses": {
36+
"200": {
37+
"description": "A successful response.",
38+
"schema": {
39+
"$ref": "#/definitions/v1SayHelloResponse"
40+
}
41+
}
42+
},
43+
"parameters": [
44+
{
45+
"name": "body",
46+
"description": "The request message containing the user's name.",
47+
"in": "body",
48+
"required": true,
49+
"schema": {
50+
"$ref": "#/definitions/v1SayHelloRequest"
51+
}
52+
},
53+
{
54+
"name": "token",
55+
"description": "Token Header",
56+
"in": "header",
57+
"required": true,
58+
"type": "string"
59+
}
60+
],
61+
"tags": [
62+
"Project 001"
63+
]
64+
}
65+
},
66+
"/v1/helloworld.Greeter/SayHello/{name}": {
67+
"get": {
68+
"summary": "Sends a hello greeting",
69+
"operationId": "GreeterService_SayHello2",
70+
"responses": {
71+
"200": {
72+
"description": "A successful response.",
73+
"schema": {
74+
"$ref": "#/definitions/v1SayHelloResponse"
75+
}
76+
}
77+
},
78+
"parameters": [
79+
{
80+
"name": "name",
81+
"description": "name ...",
82+
"in": "path",
83+
"required": true,
84+
"type": "string"
85+
},
86+
{
87+
"name": "token",
88+
"description": "Token Header",
89+
"in": "header",
90+
"required": true,
91+
"type": "string"
92+
}
93+
],
94+
"tags": [
95+
"Project 001"
96+
]
97+
}
98+
}
99+
},
100+
"definitions": {
101+
"v1SayHelloRequest": {
102+
"type": "object",
103+
"properties": {
104+
"name": {
105+
"type": "string",
106+
"description": "name ..."
107+
}
108+
},
109+
"description": "The request message containing the user's name."
110+
},
111+
"v1SayHelloResponse": {
112+
"type": "object",
113+
"properties": {
114+
"error": {
115+
"type": "integer",
116+
"format": "int64",
117+
"title": "error"
118+
},
119+
"msg": {
120+
"type": "string",
121+
"title": "msg"
122+
},
123+
"data": {
124+
"$ref": "#/definitions/v1SayHelloResponseData",
125+
"description": "data ..."
126+
}
127+
},
128+
"title": "The response message containing the greetings"
129+
},
130+
"v1SayHelloResponseData": {
131+
"type": "object",
132+
"properties": {
133+
"name": {
134+
"type": "string",
135+
"title": "name of the user"
136+
},
137+
"ageNumber": {
138+
"type": "string",
139+
"format": "uint64",
140+
"description": "age_number is the age number."
141+
},
142+
"sex": {
143+
"$ref": "#/definitions/v1Sex",
144+
"title": "sex is the user's sex"
145+
},
146+
"metadata": {
147+
"type": "object",
148+
"additionalProperties": {
149+
"type": "string"
150+
},
151+
"title": "metadata is the user's metadata"
152+
}
153+
},
154+
"description": "Data is the data to be sent."
155+
},
156+
"v1SayHiResponse": {
157+
"type": "object",
158+
"properties": {
159+
"error": {
160+
"type": "integer",
161+
"format": "int64",
162+
"title": "error"
163+
},
164+
"msg": {
165+
"type": "string",
166+
"title": "msg"
167+
},
168+
"data": {
169+
"$ref": "#/definitions/v1SayHiResponseData",
170+
"description": "data ..."
171+
}
172+
},
173+
"title": "The response message containing the greetings"
174+
},
175+
"v1SayHiResponseData": {
176+
"type": "object",
177+
"properties": {
178+
"name": {
179+
"type": "string",
180+
"title": "name of the user"
181+
},
182+
"ageNumber": {
183+
"type": "string",
184+
"format": "uint64",
185+
"description": "age_number is the age number."
186+
}
187+
},
188+
"description": "Data is the data to be sent."
189+
},
190+
"v1Sex": {
191+
"type": "integer",
192+
"format": "int32",
193+
"enum": [
194+
1,
195+
2
196+
],
197+
"description": "- 1: SEX_MALE ...\n - 2: SEX_FEMALE ...",
198+
"title": "Sex"
199+
}
200+
}
201+
}

api/error/v1/error.pb.go

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)