ldej / swagger-go-example Goto Github PK
View Code? Open in Web Editor NEWAn 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/
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/
Run the 3 commands on a fresh install
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
make install_deps && make swagger && make run
cf logs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.