From cf7301c78f209e1667a90139d2a4513de977f3e7 Mon Sep 17 00:00:00 2001 From: Felipe Martin <812088+fmartingr@users.noreply.github.com> Date: Thu, 28 Dec 2023 18:37:19 +0100 Subject: [PATCH] Fixed lint errors after refactor (#806) * removed git diff from swagger check script * updated swagger docs * removed ununsed calls --- docs/swagger/docs.go | 6 ++++-- docs/swagger/swagger.json | 6 ++++-- docs/swagger/swagger.yaml | 6 ++++-- internal/http/routes/api/v1/bookmarks.go | 2 +- internal/webserver/utils.go | 18 ------------------ scripts/swagger_check.sh | 3 --- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index ef6f0d9b8..5da1ffb4b 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -150,7 +150,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/model.Bookmark" + "$ref": "#/definitions/model.BookmarkDTO" } }, "403": { @@ -294,16 +294,18 @@ const docTemplate = `{ } } }, - "model.Bookmark": { + "model.BookmarkDTO": { "type": "object", "properties": { "author": { "type": "string" }, "create_archive": { + "description": "TODO: migrate outside the DTO", "type": "boolean" }, "create_ebook": { + "description": "TODO: migrate outside the DTO", "type": "boolean" }, "excerpt": { diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 928908956..58a6d7be7 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -139,7 +139,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/model.Bookmark" + "$ref": "#/definitions/model.BookmarkDTO" } }, "403": { @@ -283,16 +283,18 @@ } } }, - "model.Bookmark": { + "model.BookmarkDTO": { "type": "object", "properties": { "author": { "type": "string" }, "create_archive": { + "description": "TODO: migrate outside the DTO", "type": "boolean" }, "create_ebook": { + "description": "TODO: migrate outside the DTO", "type": "boolean" }, "excerpt": { diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 611cff6df..6935a30b3 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -57,13 +57,15 @@ definitions: username: type: string type: object - model.Bookmark: + model.BookmarkDTO: properties: author: type: string create_archive: + description: 'TODO: migrate outside the DTO' type: boolean create_ebook: + description: 'TODO: migrate outside the DTO' type: boolean excerpt: type: string @@ -210,7 +212,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/model.Bookmark' + $ref: '#/definitions/model.BookmarkDTO' "403": description: Token not provided/invalid summary: Update Cache and Ebook on server. diff --git a/internal/http/routes/api/v1/bookmarks.go b/internal/http/routes/api/v1/bookmarks.go index acf23521b..ccea76ff1 100644 --- a/internal/http/routes/api/v1/bookmarks.go +++ b/internal/http/routes/api/v1/bookmarks.go @@ -202,7 +202,7 @@ func (r *BookmarksAPIRoutes) deleteHandler(c *gin.Context) { // @securityDefinitions.apikey ApiKeyAuth // @Param payload body updateCachePayload true "Update Cache Payload"` // @Produce json -// @Success 200 {object} model.Bookmark +// @Success 200 {object} model.BookmarkDTO // @Failure 403 {object} nil "Token not provided/invalid" // @Router /api/v1/bookmarks/cache [put] func (r *BookmarksAPIRoutes) updateCache(c *gin.Context) { diff --git a/internal/webserver/utils.go b/internal/webserver/utils.go index 39fd8ff5c..7fe8ab733 100644 --- a/internal/webserver/utils.go +++ b/internal/webserver/utils.go @@ -4,28 +4,10 @@ import ( "html/template" "io" "net" - "net/http" - nurl "net/url" "os" "syscall" ) -func createRedirectURL(newPath, previousPath string) string { - urlQueries := nurl.Values{} - urlQueries.Set("dst", previousPath) - - redirectURL, _ := nurl.Parse(newPath) - redirectURL.RawQuery = urlQueries.Encode() - return redirectURL.String() -} - -func redirectPage(w http.ResponseWriter, r *http.Request, url string) { - w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") - w.Header().Set("Pragma", "no-cache") - w.Header().Set("Expires", "0") - http.Redirect(w, r, url, http.StatusMovedPermanently) -} - func FileExists(filePath string) bool { info, err := os.Stat(filePath) return err == nil && !info.IsDir() diff --git a/scripts/swagger_check.sh b/scripts/swagger_check.sh index ee6105c84..e512bad56 100644 --- a/scripts/swagger_check.sh +++ b/scripts/swagger_check.sh @@ -12,7 +12,6 @@ fi # Check if the git tree for CWD is clean if [ -n "$(git status docs/swagger --porcelain)" ]; then echo "❌ git tree is not clean. Please commit all changes before running this script." - git diff exit 1 fi @@ -20,7 +19,6 @@ fi make swag-fmt if [ -n "$(git status docs/swagger --porcelain)" ]; then echo "❌ swag comments are not formatted. Please run 'make swag-fmt' and commit the changes." - git diff git checkout -- docs/swagger exit 1 fi @@ -29,7 +27,6 @@ fi make swagger if [ -n "$(git status docs/swagger --porcelain)" ]; then echo "❌ swagger documentation not updated, please run 'make swagger' and commit the changes." - git diff git checkout -- docs/swagger exit 1 fi