Add swag-generate to justfile and include in build

This commit is contained in:
2026-05-18 21:44:58 +02:00
parent 1d77ae491c
commit f03e001bdd
2 changed files with 26 additions and 14 deletions
+6 -12
View File
@@ -87,12 +87,12 @@ type swaggerInfo struct {
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/",
Schemes: []string{"http", "https"},
Title: "MusicServer API",
Description: "API for the MusicServer application",
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
}
type s struct{}
@@ -129,9 +129,3 @@ func (s *s) ReadDoc() string {
func init() {
swag.Register("swagger", &s{})
}
// GetSwaggerJSON returns the swagger JSON
func GetSwaggerJSON() string {
s := &s{}
return s.ReadDoc()
}
+20 -2
View File
@@ -41,10 +41,28 @@ sqlc-generate:
migrate-create name:
@migrate create -ext sql -dir internal/db/migrations -seq {{name}}
swag-install:
@if ! command -v swag > /dev/null; then \
read -p "Swag is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/swaggo/swag/cmd/swag@latest; \
if [ ! -x "$$(command -v swag)" ]; then \
echo "swag installation failed. Exiting..."; \
exit 1; \
fi; \
else \
echo "You chose not to install swag. Exiting..."; \
exit 1; \
fi; \
fi
swag-generate: swag-install
@echo "Generating OpenAPI docs..."
@swag init -g internal/server/routes.go -o cmd/docs
[no-cd]
build: sqlc-generate templ-build tailwind-build
build: sqlc-generate templ-build tailwind-build swag-generate
@echo "Building..."
@swag init -g routes.go -d ./internal/server/,./internal/backend/ -o ./cmd/docs
@go build -o main cmd/main.go
run: