Add swag-generate to justfile and include in build
This commit is contained in:
+6
-12
@@ -87,12 +87,12 @@ type swaggerInfo struct {
|
|||||||
|
|
||||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||||
var SwaggerInfo = swaggerInfo{
|
var SwaggerInfo = swaggerInfo{
|
||||||
Version: "1.0",
|
Version: "",
|
||||||
Host: "localhost:8080",
|
Host: "",
|
||||||
BasePath: "/",
|
BasePath: "",
|
||||||
Schemes: []string{"http", "https"},
|
Schemes: []string{},
|
||||||
Title: "MusicServer API",
|
Title: "",
|
||||||
Description: "API for the MusicServer application",
|
Description: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
type s struct{}
|
type s struct{}
|
||||||
@@ -129,9 +129,3 @@ func (s *s) ReadDoc() string {
|
|||||||
func init() {
|
func init() {
|
||||||
swag.Register("swagger", &s{})
|
swag.Register("swagger", &s{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSwaggerJSON returns the swagger JSON
|
|
||||||
func GetSwaggerJSON() string {
|
|
||||||
s := &s{}
|
|
||||||
return s.ReadDoc()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,10 +41,28 @@ sqlc-generate:
|
|||||||
migrate-create name:
|
migrate-create name:
|
||||||
@migrate create -ext sql -dir internal/db/migrations -seq {{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]
|
[no-cd]
|
||||||
build: sqlc-generate templ-build tailwind-build
|
build: sqlc-generate templ-build tailwind-build swag-generate
|
||||||
@echo "Building..."
|
@echo "Building..."
|
||||||
@swag init -g routes.go -d ./internal/server/,./internal/backend/ -o ./cmd/docs
|
|
||||||
@go build -o main cmd/main.go
|
@go build -o main cmd/main.go
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
|||||||
Reference in New Issue
Block a user