From 7f81c14a97167ff9f14677b42142cfde34b73548 Mon Sep 17 00:00:00 2001 From: golangisfun123 Date: Wed, 1 May 2024 10:56:43 -0500 Subject: [PATCH] swagger, lint --- contrib/screener-api/db/sql/base/namer.go | 1 - contrib/screener-api/docs/docs.go | 53 ++++++++++++++++++++- contrib/screener-api/docs/swagger.json | 53 ++++++++++++++++++++- contrib/screener-api/docs/swagger.yaml | 37 +++++++++++++- contrib/screener-api/go.mod | 2 + contrib/screener-api/go.sum | 7 +++ contrib/screener-api/screener/screener.go | 8 +++- contrib/screener-api/screener/suite_test.go | 1 - 8 files changed, 155 insertions(+), 7 deletions(-) diff --git a/contrib/screener-api/db/sql/base/namer.go b/contrib/screener-api/db/sql/base/namer.go index c69ba15a00..7d305d7052 100644 --- a/contrib/screener-api/db/sql/base/namer.go +++ b/contrib/screener-api/db/sql/base/namer.go @@ -5,7 +5,6 @@ import ( ) func init() { - // idk what this is namer := dbcommon.NewNamer(GetAllModels()) addressName = namer.GetConsistentName("Address") diff --git a/contrib/screener-api/docs/docs.go b/contrib/screener-api/docs/docs.go index 6676994c29..82b79492f0 100644 --- a/contrib/screener-api/docs/docs.go +++ b/contrib/screener-api/docs/docs.go @@ -14,7 +14,58 @@ const docTemplate = `{ }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", - "paths": {} + "paths": { + "/api/data/sync": { + "post": { + "description": "blacklist an address", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "blacklist an address", + "parameters": [ + { + "type": "string", + "description": "Application ID", + "name": "appid", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Timestamp of the request", + "name": "timestamp", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "A unique nonce for the request", + "name": "nonce", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Query string parameters included in the request", + "name": "queryString", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Signature for request validation", + "name": "signature", + "in": "header", + "required": true + } + ], + "responses": {} + } + } + } }` // SwaggerInfo holds exported Swagger Info so clients can modify it diff --git a/contrib/screener-api/docs/swagger.json b/contrib/screener-api/docs/swagger.json index ec416cd4a1..6e7bdb33ab 100644 --- a/contrib/screener-api/docs/swagger.json +++ b/contrib/screener-api/docs/swagger.json @@ -3,5 +3,56 @@ "info": { "contact": {} }, - "paths": {} + "paths": { + "/api/data/sync": { + "post": { + "description": "blacklist an address", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "blacklist an address", + "parameters": [ + { + "type": "string", + "description": "Application ID", + "name": "appid", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Timestamp of the request", + "name": "timestamp", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "A unique nonce for the request", + "name": "nonce", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Query string parameters included in the request", + "name": "queryString", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "Signature for request validation", + "name": "signature", + "in": "header", + "required": true + } + ], + "responses": {} + } + } + } } \ No newline at end of file diff --git a/contrib/screener-api/docs/swagger.yaml b/contrib/screener-api/docs/swagger.yaml index b64379cad9..86cde195b7 100644 --- a/contrib/screener-api/docs/swagger.yaml +++ b/contrib/screener-api/docs/swagger.yaml @@ -1,4 +1,39 @@ info: contact: {} -paths: {} +paths: + /api/data/sync: + post: + consumes: + - application/json + description: blacklist an address + parameters: + - description: Application ID + in: header + name: appid + required: true + type: string + - description: Timestamp of the request + in: header + name: timestamp + required: true + type: string + - description: A unique nonce for the request + in: header + name: nonce + required: true + type: string + - description: Query string parameters included in the request + in: header + name: queryString + required: true + type: string + - description: Signature for request validation + in: header + name: signature + required: true + type: string + produces: + - application/json + responses: {} + summary: blacklist an address swagger: "2.0" diff --git a/contrib/screener-api/go.mod b/contrib/screener-api/go.mod index d3a3d84422..dc228d24f7 100644 --- a/contrib/screener-api/go.mod +++ b/contrib/screener-api/go.mod @@ -18,6 +18,8 @@ require ( github.com/ipfs/go-log v1.0.5 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/stretchr/testify v1.8.4 + github.com/swaggo/files v1.0.1 + github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.3 github.com/synapsecns/sanguine/core v0.0.0-00010101000000-000000000000 github.com/urfave/cli/v2 v2.27.1 diff --git a/contrib/screener-api/go.sum b/contrib/screener-api/go.sum index 2a85bc4482..5263afa49b 100644 --- a/contrib/screener-api/go.sum +++ b/contrib/screener-api/go.sum @@ -148,6 +148,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/requestid v0.0.6 h1:mGcxTnHQ45F6QU5HQRgQUDsAfHprD3P7g2uZ4cSZo9o= github.com/gin-contrib/requestid v0.0.6/go.mod h1:9i4vKATX/CdggbkY252dPVasgVucy/ggBeELXuQztm4= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -475,6 +477,10 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= +github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= +github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M= +github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -667,6 +673,7 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= diff --git a/contrib/screener-api/screener/screener.go b/contrib/screener-api/screener/screener.go index 4dc62d035a..b6e18d4059 100644 --- a/contrib/screener-api/screener/screener.go +++ b/contrib/screener-api/screener/screener.go @@ -134,10 +134,14 @@ func (s *screenerImpl) fetchBlacklist(ctx context.Context) { // @dev Protected Method // @Summary blacklist an address // @Description blacklist an address -// @Param request body appsecret appid timestamp nonce queryString BlackListBody +// @Param appid header string true "Application ID" +// @Param timestamp header string true "Timestamp of the request" +// @Param nonce header string true "A unique nonce for the request" +// @Param queryString header string true "Query string parameters included in the request" +// @Param signature header string true "Signature for request validation" // @Accept json // @Produce json -// @Router /api/data/sync [post] +// @Router /api/data/sync [post]. func (s *screenerImpl) blacklistAddress(c *gin.Context) { var blacklistBody client.BlackListBody diff --git a/contrib/screener-api/screener/suite_test.go b/contrib/screener-api/screener/suite_test.go index fb047436a1..aa759d400e 100644 --- a/contrib/screener-api/screener/suite_test.go +++ b/contrib/screener-api/screener/suite_test.go @@ -189,7 +189,6 @@ func (s *ScreenerSuite) TestScreener() { status, err = apiClient.BlacklistAddress(s.GetTestContext(), "bad", cfg.AppID, blacklistBody) NotEqual(s.T(), "success", status) NotNil(s.T(), err) - } type mockClient struct {