Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Swagger documentation and add BasicAuth #82

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected]

// @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"
Loading