File tree 6 files changed +57
-8
lines changed
6 files changed +57
-8
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,16 @@ const docTemplate = `{
9
9
"info": {
10
10
"description": "{{escape .Description}}",
11
11
"title": "{{.Title}}",
12
- "contact": {},
12
+ "termsOfService": "https://tos.santoshk.dev",
13
+ "contact": {
14
+ "name": "Santosh Kumar",
15
+ "url": "https://twitter.com/sntshk",
16
+
17
+ },
18
+ "license": {
19
+ "name": "Apache 2.0",
20
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
21
+ },
13
22
"version": "{{.Version}}"
14
23
},
15
24
"host": "{{.Host}}",
@@ -19,12 +28,12 @@ const docTemplate = `{
19
28
20
29
// SwaggerInfo holds exported Swagger Info so clients can modify it
21
30
var SwaggerInfo = & swag.Spec {
22
- Version : "" ,
23
- Host : "" ,
31
+ Version : "1.0 " ,
32
+ Host : "localhost:3001 " ,
24
33
BasePath : "" ,
25
34
Schemes : []string {},
26
- Title : "" ,
27
- Description : "" ,
35
+ Title : "Gin Book Service " ,
36
+ Description : "A book management service API in Go using Gin framework. " ,
28
37
InfoInstanceName : "swagger" ,
29
38
SwaggerTemplate : docTemplate ,
30
39
LeftDelim : "{{" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"swagger" : " 2.0" ,
3
3
"info" : {
4
- "contact" : {}
4
+ "description" : " A book management service API in Go using Gin framework." ,
5
+ "title" : " Gin Book Service" ,
6
+ "termsOfService" : " https://tos.santoshk.dev" ,
7
+ "contact" : {
8
+ "name" : " Santosh Kumar" ,
9
+ "url" : " https://twitter.com/sntshk" ,
10
+
11
+ },
12
+ "license" : {
13
+ "name" : " Apache 2.0" ,
14
+ "url" : " http://www.apache.org/licenses/LICENSE-2.0.html"
15
+ },
16
+ "version" : " 1.0"
5
17
},
18
+ "host" : " localhost:3001" ,
6
19
"paths" : {}
7
20
}
Original file line number Diff line number Diff line change
1
+ host : localhost:3001
1
2
info :
2
- contact : {}
3
+ contact :
4
+
5
+ name : Santosh Kumar
6
+ url : https://twitter.com/sntshk
7
+ description : A book management service API in Go using Gin framework.
8
+ license :
9
+ name : Apache 2.0
10
+ url : http://www.apache.org/licenses/LICENSE-2.0.html
11
+ termsOfService : https://tos.santoshk.dev
12
+ title : Gin Book Service
13
+ version : " 1.0"
3
14
paths : {}
4
15
swagger : " 2.0"
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ require (
19
19
github.com/go-openapi/swag v0.22.7 // indirect
20
20
github.com/go-playground/locales v0.14.1 // indirect
21
21
github.com/go-playground/universal-translator v0.18.1 // indirect
22
- github.com/go-playground/validator/v10 v10.16 .0 // indirect
22
+ github.com/go-playground/validator/v10 v10.17 .0 // indirect
23
23
github.com/goccy/go-json v0.10.2 // indirect
24
24
github.com/josharian/intern v1.0.0 // indirect
25
25
github.com/json-iterator/go v1.1.12 // indirect
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
39
39
github.com/go-playground/universal-translator v0.18.1 /go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY =
40
40
github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE =
41
41
github.com/go-playground/validator/v10 v10.16.0 /go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU =
42
+ github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74 =
43
+ github.com/go-playground/validator/v10 v10.17.0 /go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU =
42
44
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU =
43
45
github.com/goccy/go-json v0.10.2 /go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I =
44
46
github.com/golang/protobuf v1.5.0 /go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk =
Original file line number Diff line number Diff line change @@ -8,6 +8,19 @@ import (
8
8
ginSwagger "github.com/swaggo/gin-swagger"
9
9
)
10
10
11
+ // @title Gin Book Service
12
+ // @version 1.0
13
+ // @description A book management service API in Go using Gin framework.
14
+ // @termsOfService https://tos.santoshk.dev
15
+
16
+ // @contact.name Santosh Kumar
17
+ // @contact.url https://twitter.com/sntshk
18
+ // @contact.email [email protected]
19
+
20
+ // @license.name Apache 2.0
21
+ // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
22
+
23
+ // @host localhost:3001
11
24
func main () {
12
25
13
26
router := gin .Default ()
@@ -20,6 +33,7 @@ func main() {
20
33
router .GET ("/user" , getUsers )
21
34
router .POST ("/user" , addUser )
22
35
router .GET ("/userData/:id" , getUserByID )
36
+
23
37
router .GET ("/swagger/*any" , ginSwagger .WrapHandler (swaggerFiles .Handler ))
24
38
25
39
router .Run (":3001" )
You can’t perform that action at this time.
0 commit comments