GithubHelp home page GithubHelp logo

ldej / swagger-go-example Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 3.0 3.3 MB

An example setup for generating swagger docs using go-swagger and swaggo. Read the blog post for details!

Home Page: https://ldej.nl/post/generating-swagger-docs-from-go/

Makefile 1.26% Go 74.34% HTML 24.40%
go golang openapi swagger

swagger-go-example's Introduction

swagger-go-example's People

Contributors

ldej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

swagger-go-example's Issues

[Bug] install_deps install not the CLI swag without go install

Description

Run the 3 commands on a fresh install

Reproduction

cd swagger-go-example/swaggo
swagger-go-example/swaggo on ๎‚  master [!] via ๐Ÿน v1.19.1
โžœ make install_deps && make swagger && make run
go get -u github.com/swaggo/swag/cmd/swag
go: downloading github.com/swaggo/swag v1.8.6
go: downloading github.com/urfave/cli/v2 v2.3.0
go: downloading github.com/go-openapi/spec v0.20.4
go: downloading github.com/KyleBanks/depth v1.2.1
go: downloading github.com/go-openapi/jsonreference v0.19.6
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/PuerkitoBio/purell v1.2.0
go: downloading github.com/go-openapi/swag v0.19.15
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
go: downloading github.com/urfave/cli v1.22.10
go: downloading github.com/urfave/cli/v2 v2.17.1
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.2
go: downloading golang.org/x/net v0.0.0-20221002022538-bcab6841153b
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
go: downloading github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go: upgraded github.com/PuerkitoBio/purell v1.1.1 => v1.2.0
go: upgraded github.com/go-openapi/spec v0.20.3 => v0.20.7
go: upgraded github.com/go-openapi/swag v0.19.15 => v0.22.3
go: upgraded github.com/swaggo/swag v1.7.0 => v1.8.6
go: upgraded github.com/urfave/cli/v2 v2.3.0 => v2.17.1
go: upgraded golang.org/x/net v0.0.0-20210525063256-abc453219eb5 => v0.0.0-20221002022538-bcab6841153b
go: upgraded golang.org/x/sys v0.0.0-20210521203332-0cec03c779c1 => v0.0.0-20220928140112-f11e5e49a4ec
go: upgraded golang.org/x/tools v0.1.1 => v0.1.12
swag init -g ./server.go -o ./swagger
make: swag: No such file or directory
make: *** [swagger] Error 1

swagger-go-example/swaggo on ๎‚  master [!] via ๐Ÿน v1.19.1 took 4s
โžœ ls
go.mod  go.sum  main.go  Makefile  server.go  swagger  thing_api.go

swagger-go-example/swaggo on ๎‚  master [!] via ๐Ÿน v1.19.1
โžœ go install github.com/swaggo/swag/cmd/swag@latest
go: downloading github.com/mailru/easyjson v0.7.6

swagger-go-example/swaggo on ๎‚  master [!] via ๐Ÿน v1.19.1 took 6s
โžœ make install_deps && make swagger && make run
go get -u github.com/swaggo/swag/cmd/swag
swag init -g ./server.go -o ./swagger
2022/10/03 17:03:02 Generate swagger docs....
2022/10/03 17:03:02 Generate general API Info, search dir:./
2022/10/03 17:03:03 Generating main.ThingResponse
2022/10/03 17:03:03 Generating main.ErrorResponse
2022/10/03 17:03:03 Generating main.CreateThing
2022/10/03 17:03:03 Generating main.UpdateThing
2022/10/03 17:03:03 Generating main.ThingsResponse
2022/10/03 17:03:03 create docs.go at  swagger/docs.go
2022/10/03 17:03:03 create swagger.json at  swagger/swagger.json
2022/10/03 17:03:03 create swagger.yaml at  swagger/swagger.yaml
go run .
2022/10/03 17:03:08 context.Background Listening on: :8080

Expectation

make install_deps && make swagger && make run

Screenshots

cf logs

Environment

  • Device: laptop
  • OS: macOS 11.7
  • Browser: Firefox 115.0.1
  • Version: Go 1.19.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.