swaggest / swgui Goto Github PK
View Code? Open in Web Editor NEWThis project forked from lazada/swgui
Embedded Swagger UI for Go
Home Page: https://pkg.go.dev/github.com/swaggest/swgui
License: Apache License 2.0
This project forked from lazada/swgui
Embedded Swagger UI for Go
Home Page: https://pkg.go.dev/github.com/swaggest/swgui
License: Apache License 2.0
The dependant golang.org/x/[email protected] library has following security issues:
GHSA-69ch-w2m2-3vjp
GHSA-ppp9-7jff-5vj2
Plz consider to upgrade it if possible.
Thanks
I tried to use swaggest in my project today and I can't get the swaggest URL's to play nice with static files.
My goal was to have /api/...
and /api/docs
be provided by swaggest, with / being passed on to a http.FileServer
, but using chi.Mount()
to relocate swaggest from /
to /api/
causes the swgui to 404 - but the actual REST connectors work just fine.
My code looks something like this (trimmed here for brevity):
func main() {
// setup REST interface with OpenAPI documentation
s := web.DefaultService()
s.OpenAPI.Info.Title = "..."
s.OpenAPI.Info.WithDescription("...")
s.OpenAPI.Info.Version = "v0.0.1"
s.Get("/item/{id}", getItemByID())
// etc...
s.Docs("/docs", v4emb.New)
// static html/css/js files served from embedded FS
uiFS := webui.StaticFS()
// top-level router
r := chi.NewRouter()
r.Mount("/api/v1", s) // relocate swaggest to /api/v1/...
r.Mount("/", http.FileServer(http.FS(uiFS))) // provide static files at /
http.ListenAndServe("localhost:8080", r)
}
My problem here is that I have two different handlers (swaggest & http.FileServer
) and chi only allows one to be mounted on "/", so I can't just use s.Get("/api/v1/item/{id}",...)
because then I can't have the html files at "/"
If anyone has any working examples of having swaggest play nicely with other sub-routers, I'd be most interested.
by the way, I tried Mounting the FileServer on "/static", but that also didn't work. I'm thinking this may be an issue with chi :-/
Thanks in advance
The indirect dependency golang.org/x/[email protected] is vulnerable according to:
GHSA-vvpx-j8f3-3w6h
GHSA-69cg-p879-7622
I’m having trouble using the v5emb
module with my current setup, as the static assets are being referenced to without the base path of my application.
In my environments applications run behind an ingress with path-based routing inside a Kubernetes cluster.
Meaning for instance that Api1 receives its request with URL http://localhost/api1/…
. All of the static assets are being attempted to be loaded using http://localhost/…]
(notice the missing api1
.
I believe there is way of configuring this asset base path using vearutop/statigz? But I don’t understand how to do so.
Any chance of someone shedding some light on this for me?
I think i found sort of a bug with urlencoding of slashes.
Here what's going on:
I have an endpoint /api/hello/{name}
In the UI I enter "World" for Name.
This is now the Request URL http://localhost:8080/api/hello/World
In the UI I enter "World/of/bugs" for {name}
.
This is now the Request URL http://localhost:8080/api/hello/World%2Fof%2Fbugs
However - this is wrong. The webserver will resolve this to this:
[GIN] 2021/04/04 - 23:49:31 | 404 | 2.853µs | 172.17.0.1 | GET "/api/hello/World/of/bugs"
Which is wrong :) That is simply a different endpoint. It is /api/hello/{a}/{b}/{c}
and not /api/hello/{name}
.
Slashes (maybe other stuff?) needs to be double encoded like this. Not just a singletime urlencoded :)
http://localhost:8080/api/hello/World%252Fof%252Fbugs
This is how it will arrive on the webserver:
[GIN] 2021/04/04 - 23:52:28 | 200 | 1.221707ms | 172.17.0.1 | GET "/api/hello/World%2Fof%2Fbugs"
Which is now the correct data in the application:
{
"message": "Hello, World/of/bugs!"
}
Please double check...
$ go get github.com/swaggest/swgui/...
go: downloading golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
go: downloading golang.org/x/text v0.3.2
# github.com/vearutop/statigz
/home/pi/.golib/pkg/mod/github.com/vearutop/[email protected]/server.go:265:22: constant 9223372036854775807 overflows int
My GO version: $ go version
go version go1.16.2 linux/arm
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.