Skip to content

Commit

Permalink
Fixed lint errors after refactor (#806)
Browse files Browse the repository at this point in the history
* removed git diff from swagger check script

* updated swagger docs

* removed ununsed calls
  • Loading branch information
fmartingr authored Dec 28, 2023
1 parent cc7c751 commit cf7301c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
6 changes: 4 additions & 2 deletions docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
"$ref": "#/definitions/model.BookmarkDTO"
}
},
"403": {
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
"$ref": "#/definitions/model.BookmarkDTO"
}
},
"403": {
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion internal/http/routes/api/v1/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 0 additions & 18 deletions internal/webserver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions scripts/swagger_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ 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

# Check swag comments
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
Expand All @@ -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

0 comments on commit cf7301c

Please sign in to comment.