Skip to content

Commit

Permalink
Fixed swag init
Browse files Browse the repository at this point in the history
  • Loading branch information
applejag committed May 28, 2021
1 parent c7c0a25 commit 05c4fc8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM golang:1.13.4 AS build
FROM golang:1.16.4 AS build
WORKDIR /src
ENV GO111MODULE=on
RUN go get -u github.com/swaggo/swag/cmd/swag@v1.6.5
RUN go get -u github.com/swaggo/swag/cmd/swag@v1.7.0
COPY . /src
ARG BUILD_VERSION="local docker"
ARG BUILD_GIT_COMMIT="HEAD"
ARG BUILD_REF="0"
RUN deploy/update-version.sh version.yaml \
&& swag init \
&& swag init --parseDependency --parseDepth 1 \
&& go get -t -d \
&& CGO_ENABLED=0 go build -o main \
&& go test -v
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gitlab.com is not well tested.
$ cd wharf-provider-github

# Generate the files into docs/
$ swag
$ swag init --parseDependency --parseDepth 1
```

4. Start hacking with your favorite tool. For example VS Code, GoLand,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/iver-wharf/wharf-provider-gitlab

go 1.13
go 1.16

require (
github.com/gin-contrib/cors v1.3.0
Expand Down
8 changes: 4 additions & 4 deletions import.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
// @Accept json
// @Produce json
// @Param import body main.Import _ "import object"
// @Success 200 "OK"
// @Failure 400 "Bad request"
// @Failure 401 "Unauthorized or missing jwt token"
// @Success 201 "Successfully imported"
// @Failure 400 {object} string "Bad request"
// @Failure 401 {object} string "Unauthorized or missing jwt token"
// @Router /gitlab [post]
func runGitLabHandler(c *gin.Context) {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
Expand Down Expand Up @@ -48,7 +48,7 @@ func runGitLabHandler(c *gin.Context) {
return
}

c.JSON(http.StatusOK, "OK")
c.Status(http.StatusCreated)
}

func handleError(c *gin.Context, err error) bool {
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"os"

"github.com/gin-contrib/cors"
Expand Down Expand Up @@ -29,7 +30,12 @@ const ProviderName = "gitlab"
// @contact.email wharf@iver.se
// @basePath /import
func main() {
docs.SwaggerInfo.Version = ApiVersion.Version
if err := loadEmbeddedVersionFile(); err != nil {
fmt.Println("Failed to read embedded version.yaml file:", err)
os.Exit(1)
}

docs.SwaggerInfo.Version = AppVersion.Version

initLogger(log.TraceLevel)

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func loadEmbeddedVersionFile() error {
// @summary Returns the version of this API
// @tags meta
// @success 200 {object} app.Version
// @router /github/version [get]
// @router /gitlab/version [get]
func getVersionHandler(c *gin.Context) {
c.JSON(http.StatusOK, AppVersion)
}

0 comments on commit 05c4fc8

Please sign in to comment.