Skip to content

Commit

Permalink
Add auth and metadata to swagger docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineAfia committed Oct 1, 2024
1 parent c4aef07 commit 4876044
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
10 changes: 1 addition & 9 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ var (
// @title Thirdweb Insight
// @version v0.0.1-beta
// @description API for querying blockchain transactions and events
// @termsOfService http://swagger.io/terms/

// @contact.name Thirdweb Support
// @contact.url https://thirdweb.com/support
// @contact.email support@thirdweb.com

// @license.name Apache 2.0
// @license.url https://github.com/thirdweb-dev/indexer/blob/main/LICENSE

// @host localhost:3000
// @BasePath /

// @Security BasicAuth
// @securityDefinitions.basic BasicAuth

func RunApi(cmd *cobra.Command, args []string) {
r := gin.New()
r.Use(gin.Logger())
Expand Down
26 changes: 20 additions & 6 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const docTemplate = `{
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {
"name": "Apache 2.0",
"url": "https://github.com/thirdweb-dev/indexer/blob/main/LICENSE"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
Expand Down Expand Up @@ -934,17 +938,27 @@ const docTemplate = `{
}
}
}
}
},
"securityDefinitions": {
"BasicAuth": {
"type": "basic"
}
},
"security": [
{
"BasicAuth": []
}
]
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "",
Host: "",
BasePath: "",
Version: "v0.0.1-beta",
Host: "localhost:3000",
BasePath: "/",
Schemes: []string{},
Title: "",
Description: "",
Title: "Thirdweb Insight",
Description: "API for querying blockchain transactions and events",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
Expand Down
23 changes: 21 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{
"swagger": "2.0",
"info": {
"contact": {}
"description": "API for querying blockchain transactions and events",
"title": "Thirdweb Insight",
"contact": {},
"license": {
"name": "Apache 2.0",
"url": "https://github.com/thirdweb-dev/indexer/blob/main/LICENSE"
},
"version": "v0.0.1-beta"
},
"host": "localhost:3000",
"basePath": "/",
"paths": {
"/{chainId}/events": {
"get": {
Expand Down Expand Up @@ -923,5 +932,15 @@
}
}
}
}
},
"securityDefinitions": {
"BasicAuth": {
"type": "basic"
}
},
"security": [
{
"BasicAuth": []
}
]
}
13 changes: 13 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
basePath: /
definitions:
api.Error:
description: Error represents an API error response
Expand Down Expand Up @@ -120,8 +121,15 @@ definitions:
value:
type: string
type: object
host: localhost:3000
info:
contact: {}
description: API for querying blockchain transactions and events
license:
name: Apache 2.0
url: https://github.com/thirdweb-dev/indexer/blob/main/LICENSE
title: Thirdweb Insight
version: v0.0.1-beta
paths:
/{chainId}/events:
get:
Expand Down Expand Up @@ -592,4 +600,9 @@ paths:
summary: Get transactions by contract and signature
tags:
- transactions
security:
- BasicAuth: []
securityDefinitions:
BasicAuth:
type: basic
swagger: "2.0"

0 comments on commit 4876044

Please sign in to comment.