Skip to content

Commit 4876044

Browse files
author
Amine Afia
committed
Add auth and metadata to swagger docs
1 parent c4aef07 commit 4876044

File tree

4 files changed

+55
-17
lines changed

4 files changed

+55
-17
lines changed

cmd/api.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,12 @@ var (
2929
// @title Thirdweb Insight
3030
// @version v0.0.1-beta
3131
// @description API for querying blockchain transactions and events
32-
// @termsOfService http://swagger.io/terms/
33-
34-
// @contact.name Thirdweb Support
35-
// @contact.url https://thirdweb.com/support
36-
// @contact.email [email protected]
37-
3832
// @license.name Apache 2.0
3933
// @license.url https://github.com/thirdweb-dev/indexer/blob/main/LICENSE
40-
4134
// @host localhost:3000
4235
// @BasePath /
43-
36+
// @Security BasicAuth
4437
// @securityDefinitions.basic BasicAuth
45-
4638
func RunApi(cmd *cobra.Command, args []string) {
4739
r := gin.New()
4840
r.Use(gin.Logger())

docs/docs.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const docTemplate = `{
1010
"description": "{{escape .Description}}",
1111
"title": "{{.Title}}",
1212
"contact": {},
13+
"license": {
14+
"name": "Apache 2.0",
15+
"url": "https://github.com/thirdweb-dev/indexer/blob/main/LICENSE"
16+
},
1317
"version": "{{.Version}}"
1418
},
1519
"host": "{{.Host}}",
@@ -934,17 +938,27 @@ const docTemplate = `{
934938
}
935939
}
936940
}
937-
}
941+
},
942+
"securityDefinitions": {
943+
"BasicAuth": {
944+
"type": "basic"
945+
}
946+
},
947+
"security": [
948+
{
949+
"BasicAuth": []
950+
}
951+
]
938952
}`
939953

940954
// SwaggerInfo holds exported Swagger Info so clients can modify it
941955
var SwaggerInfo = &swag.Spec{
942-
Version: "",
943-
Host: "",
944-
BasePath: "",
956+
Version: "v0.0.1-beta",
957+
Host: "localhost:3000",
958+
BasePath: "/",
945959
Schemes: []string{},
946-
Title: "",
947-
Description: "",
960+
Title: "Thirdweb Insight",
961+
Description: "API for querying blockchain transactions and events",
948962
InfoInstanceName: "swagger",
949963
SwaggerTemplate: docTemplate,
950964
LeftDelim: "{{",

docs/swagger.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
{
22
"swagger": "2.0",
33
"info": {
4-
"contact": {}
4+
"description": "API for querying blockchain transactions and events",
5+
"title": "Thirdweb Insight",
6+
"contact": {},
7+
"license": {
8+
"name": "Apache 2.0",
9+
"url": "https://github.com/thirdweb-dev/indexer/blob/main/LICENSE"
10+
},
11+
"version": "v0.0.1-beta"
512
},
13+
"host": "localhost:3000",
14+
"basePath": "/",
615
"paths": {
716
"/{chainId}/events": {
817
"get": {
@@ -923,5 +932,15 @@
923932
}
924933
}
925934
}
926-
}
935+
},
936+
"securityDefinitions": {
937+
"BasicAuth": {
938+
"type": "basic"
939+
}
940+
},
941+
"security": [
942+
{
943+
"BasicAuth": []
944+
}
945+
]
927946
}

docs/swagger.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
basePath: /
12
definitions:
23
api.Error:
34
description: Error represents an API error response
@@ -120,8 +121,15 @@ definitions:
120121
value:
121122
type: string
122123
type: object
124+
host: localhost:3000
123125
info:
124126
contact: {}
127+
description: API for querying blockchain transactions and events
128+
license:
129+
name: Apache 2.0
130+
url: https://github.com/thirdweb-dev/indexer/blob/main/LICENSE
131+
title: Thirdweb Insight
132+
version: v0.0.1-beta
125133
paths:
126134
/{chainId}/events:
127135
get:
@@ -592,4 +600,9 @@ paths:
592600
summary: Get transactions by contract and signature
593601
tags:
594602
- transactions
603+
security:
604+
- BasicAuth: []
605+
securityDefinitions:
606+
BasicAuth:
607+
type: basic
595608
swagger: "2.0"

0 commit comments

Comments
 (0)