feat: generate swagger docs at build time
This commit is contained in:
parent
7153de5c2a
commit
efa24cec44
@ -142,7 +142,7 @@ steps:
|
|||||||
- export "GOROOT=$(go env GOROOT)"
|
- export "GOROOT=$(go env GOROOT)"
|
||||||
- apk --no-cache add build-base git
|
- apk --no-cache add build-base git
|
||||||
- wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.1
|
- wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.1
|
||||||
- ./mage-static check:all
|
- ./mage-static check:golangci
|
||||||
when:
|
when:
|
||||||
event: [ push, tag, pull_request ]
|
event: [ push, tag, pull_request ]
|
||||||
|
|
||||||
@ -385,6 +385,7 @@ steps:
|
|||||||
- export PATH=$PATH:$GOPATH/bin
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
- go install github.com/magefile/mage
|
- go install github.com/magefile/mage
|
||||||
- ./mage-static release:dirs
|
- ./mage-static release:dirs
|
||||||
|
- ./mage-static do-the-swag
|
||||||
depends_on: [ fetch-tags, mage ]
|
depends_on: [ fetch-tags, mage ]
|
||||||
|
|
||||||
- name: static-build-windows
|
- name: static-build-windows
|
||||||
@ -731,6 +732,6 @@ steps:
|
|||||||
- failure
|
- failure
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 166caa5ba66cd55bc0f1c5cb42be0a0a647fbadf66716778cf795fc084fc80fd
|
hmac: 20ae6020b7e0ac4a01e087e3ef5c17c56ead6a42205b10e5d9a28bf66ae2d8a2
|
||||||
|
|
||||||
...
|
...
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,3 +27,4 @@ vikunja-dump*
|
|||||||
vendor/
|
vendor/
|
||||||
os-packages/
|
os-packages/
|
||||||
mage_output_file.go
|
mage_output_file.go
|
||||||
|
pkg/swagger/*
|
||||||
|
@ -340,6 +340,11 @@ func Fmt() {
|
|||||||
// Generates the swagger docs from the code annotations
|
// Generates the swagger docs from the code annotations
|
||||||
func DoTheSwag() {
|
func DoTheSwag() {
|
||||||
mg.Deps(initVars)
|
mg.Deps(initVars)
|
||||||
|
if _, err := os.Stat("./pkg/swagger/swagger.json"); err == nil {
|
||||||
|
fmt.Println("Swagger docs already generated, not generating. Remove the files in pkg/swagger and run this command again to regenerate them.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
checkAndInstallGoTool("swag", "github.com/swaggo/swag/cmd/swag")
|
checkAndInstallGoTool("swag", "github.com/swaggo/swag/cmd/swag")
|
||||||
runAndStreamOutput("swag", "init", "-g", "./pkg/routes/routes.go", "--parseDependency", "-d", RootPath, "-o", RootPath+"/pkg/swagger")
|
runAndStreamOutput("swag", "init", "-g", "./pkg/routes/routes.go", "--parseDependency", "-d", RootPath, "-o", RootPath+"/pkg/swagger")
|
||||||
}
|
}
|
||||||
@ -452,6 +457,7 @@ func (Build) Clean() error {
|
|||||||
// Builds a vikunja binary, ready to run
|
// Builds a vikunja binary, ready to run
|
||||||
func (Build) Build() {
|
func (Build) Build() {
|
||||||
mg.Deps(initVars)
|
mg.Deps(initVars)
|
||||||
|
mg.Deps(DoTheSwag)
|
||||||
runAndStreamOutput("go", "build", Goflags[0], "-tags", Tags, "-ldflags", "-s -w "+Ldflags, "-o", Executable)
|
runAndStreamOutput("go", "build", Goflags[0], "-tags", Tags, "-ldflags", "-s -w "+Ldflags, "-o", Executable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +467,7 @@ type Release mg.Namespace
|
|||||||
func (Release) Release(ctx context.Context) error {
|
func (Release) Release(ctx context.Context) error {
|
||||||
mg.Deps(initVars)
|
mg.Deps(initVars)
|
||||||
mg.Deps(Release.Dirs)
|
mg.Deps(Release.Dirs)
|
||||||
|
mg.Deps(DoTheSwag)
|
||||||
|
|
||||||
// Run compiling in parallel to speed it up
|
// Run compiling in parallel to speed it up
|
||||||
errs, _ := errgroup.WithContext(ctx)
|
errs, _ := errgroup.WithContext(ctx)
|
||||||
@ -502,6 +509,7 @@ func (Release) Dirs() error {
|
|||||||
|
|
||||||
func runXgo(targets string) error {
|
func runXgo(targets string) error {
|
||||||
mg.Deps(initVars)
|
mg.Deps(initVars)
|
||||||
|
mg.Deps(DoTheSwag)
|
||||||
checkAndInstallGoTool("xgo", "src.techknowlogick.com/xgo")
|
checkAndInstallGoTool("xgo", "src.techknowlogick.com/xgo")
|
||||||
|
|
||||||
extraLdflags := `-linkmode external -extldflags "-static" `
|
extraLdflags := `-linkmode external -extldflags "-static" `
|
||||||
|
9460
pkg/swagger/docs.go
9460
pkg/swagger/docs.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user