Skip to content

Commit

Permalink
feat: annotate API handlers that requires auth with swag (#46)
Browse files Browse the repository at this point in the history
* feat: annotate API handlers that requires auth with swag

* update generated docs

* bump go swag dep

* feat: add optional auth in swag

* fix swagger
  • Loading branch information
LordNoteworthy authored Aug 16, 2023
1 parent 92224a2 commit 5ce5444
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 21 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"healthcheck",
"mpfd",
"necsfield",
"Presign",
"Robohash",
"Taymiyyah",
"templater",
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ couchbase-init: ## Init couchbase database by creating the cluster and required
--enable-flush 0 ; \
done


gen-openapi: ## Generate OpenAPI spec.
swag init --parseDepth 2 -g cmd/main.go

old="- '{}': \[\]" && new="- {}" \
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/swagger.yaml
old=' Bearer: \[\]' && new='- Bearer: []' \
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/swagger.yaml

tr -d '\n' < ${ROOT_DIR}/docs/swagger.json > ${ROOT_DIR}/docs/swagger-tmp.json
mv ${ROOT_DIR}/docs/swagger-tmp.json ${ROOT_DIR}/docs/swagger.json

old='"Bearer": \[\],' && new='"Bearer": \[\]},' \
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/swagger.json
old='"{}": \[\] }' && new="{}" \
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/swagger.json

old='"{}":' && new="- {}:" \
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/docs.go

install-swag: ## Install Swag
go install github.com/swaggo/swag/cmd/swag@latest
146 changes: 142 additions & 4 deletions docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ce5444

Please sign in to comment.