swaggo / fiber-swagger Goto Github PK
View Code? Open in Web Editor NEWfiber middleware to automatically generate RESTful API documentation with Swagger 2.0.
License: MIT License
fiber middleware to automatically generate RESTful API documentation with Swagger 2.0.
License: MIT License
I'm using swag with fiber but I can't configure correctly the swagger definition to access the documentation behind a reverse proxy or multiple accesses.
In my use case I have three ways of accessing applications' documentation:
https://my-proxy/custom/path/swag/index.html
http://123.123.1.2/swag/index.html
2.
The problem: I can't make basePath
dynamic. It will always have one single value. And because of that the Try it out
button may only work from one of those access.
Would be nice to have in swag's implementation a way of adding a prefix to the basePath in the swag.ReadDoc()
call (or a new one).
If this is implemented I will be able to change the implementation of gofiber's swagger to use the X-Forwarded-Prefix
header as prefix for the basePath using swag
.
Thanks.
Openning by requested in swaggo/swag#1210
not able to view any urls
even tried example provided.
Here is the code
package main
import (
"log"
"github.com/gofiber/fiber/v2"
fiberSwagger "github.com/swaggo/fiber-swagger"
_ "github.com/swaggo/fiber-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.
)
// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host petstore.swagger.io
// @BasePath /v2
func main() {
app := fiber.New()
app.Get("/swagger/*", fiberSwagger.WrapHandler)
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("home")
})
app.Get("/news", func(c *fiber.Ctx) error {
return c.SendString("news")
})
err := app.Listen(":4000")
if err != nil {
log.Fatalf("fiber.Listen failed %s", err)
}
}
after the i had given swag init
How can i view urls list of urls in swagger docs
I have endpoints that are authorized by a Keycloak server that uses OpenID Connect, similar to this example:
swagger-api/swagger-ui#7963
In other words, I would like to configure the underlying Swagger UI with this configuration:
"securitySchemes": {
"OpenIdConnect": {
"type": "openIdConnect",
"openIdConnectUrl": "https://my.url.com/auth/realms/myrealm/.well-known/openid-configuration"
}
}
How would I configure swag
so that it will Authorize correctly with Keycloak?
Thank you!
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.