iris-contrib / swagger Goto Github PK
View Code? Open in Web Editor NEWIris middleware to automatically generate RESTful API documentation with Swagger 2.0
License: MIT License
Iris middleware to automatically generate RESTful API documentation with Swagger 2.0
License: MIT License
When I use the POST method to accept the JSON parameter, click the Try it out
button, and swagger sends an OPTIONS type request.
here is my code:
// @Accept json
// @Param req body bean.Dog true "InstanceCreateReq"
// @Success 200 {string} string "ok"
// @Router /demo/dog [post]
the request by swagger try is:
Request URL: http://127.0.0.1:8888/demo/dog
Request Method: OPTIONS
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8888
Referrer Policy: no-referrer-when-downgrade
In the release: v12.2.0-alpha2 , the value in the go.mod is module github.com/iris-contrib/swagger
should it be module github.com/iris-contrib/swagger/v12
?
I can not download it in my project with go mod with error:
go: github.com/iris-contrib/swagger/[email protected]: go.mod has non-.../v12 module path "github.com/iris-contrib/swagger" (and .../v12/go.mod does not exist) at revision v12.2.0-alpha2
....
mvc.Configure(app.Party("/api/v1"), func(m *mvc.Application) {
m.Party("/test").Handle(new(v1.Test))
m.Party("/xiaomai").Handle(new(v1.XiaoMai))
})
.....
type XiaoMai struct {
Ctx iris.Context
}
// @Summary
// @Produce json
// @Param text string true "text"
// @Success 200 {object} restful.JsonResult
// @Failure 500 {object} restful.JsonResult
// @Router /api/v1/tiktok/parse/video
func (t *XiaoMai) PostParseVideo() *restful.JsonResult {
......
......
}
I configured DeepLinking is true , but it is not work.
When I use the url with id to access the webpage, the corresponding page cannot be opened, and the homepage is always displayed
ps: the url like this( http://localhost/index.html#/user/account_getuser )
Describe the bug
I'm generating swagger documentation by running swag init --instanceName auth
To Reproduce
Steps to reproduce the behavior:
cd <Project-Root>/swagger
swag init -dir ../cmd/myproject --instanceName main
swag init -dir ../pkg/auth --instanceName auth
swag init -dir ../pkg/anotherPackage --instanceName anotherPackage
router.GET("/swagger/main/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("main")))
router.GET("/swagger/auth/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("auth")))
router.GET("/swagger/anotherPackage/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("anotherPackage")))
For more details, please refer to this:
https://myschools.me/suguo/gin-swagger/src/commit/88c9ed2643de9f3b9fd2ac9ad03d9e63bd7721d3/example/multiple/main.go
Expected behavior
I should be able to define and use different instance names as I need to consolidate and generate swagger documentation for all of my packages at one place.
Screenshots
Not applicable
Desktop (please complete the following information):
iris.Version
Will this swagger automatic generate API docs after calling API, without pre-write annotation on API?
v1 := app.Party("/api/v1")
v1.Post("/user/login", ...
swagger path is /user/login
Hi,it can not read code annotation between to project. How can i resolve it? Thank you.
Describe the issue you are facing or ask for help
@kataras Is the document wrong?
Do you support the following formats?
@success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc"
How can I group the endpoints by Party ? Which declaration/annotation comment should I use ? I'm having this:
I need the endpoints grouped by something like "Books", "Catalogs" and so on,... not one unique unnamed "default" group. How can I achieve that?
PS: My problem is similar to this link but with Iris
Describe the bug
The latest version (v12.2.0 at the moment) is effectivly un-gettable.
To Reproduce
Steps to reproduce the behavior:
go get github.com/iris-contrib/swagger/v12@master
We get the following line in go.mod:
require github.com/iris-contrib/swagger/v12 v12.2.0-alpha //wrong version
go get github.com/iris-contrib/swagger/[email protected]
We get this error:
go: github.com/iris-contrib/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/iris-contrib/swagger/v12")
Expected behavior
We should get the correct version in go.mod:
require github.com/iris-contrib/swagger/v12 v12.2.0
Desktop (please complete the following information):
iris.Version
Additional context
The problem is due to the fact that, in the master branch, the module declaration in go.mod lacks the v12 suffix.
When i set api operations->params type-> array . The Ui notice me
Could not render this component, see the console.
? So, it's means params type is not support array
?.
Hi,
$ go run main.go
docs/docs.go:11:2: cannot find package
$
The rest of the main.go file
package main
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/recover"
"github.com/iris-contrib/swagger/v12" // swagger middleware for Iris
"github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files
"go.api.backend/api/endpoints"
_ "go.api.backend/docs"
)
// @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 localhost:8080
// #@BasePath /v2
func main() {
app := iris.New()
// Built-in
app.UseRouter(recover.New()) //Recovery middleware recovers from any panics and writes a 500 if there was one.
endpoints.BookRegister(app)
//region ======== SWAGGER REGISTRATIONS =================================================
Is your feature request related to a problem? Please describe.
My project is running locally with port 44000 but Swagger always redirects to localhost:3200. I want to change oauth2RedirectUrl so it can redirect properly.
Describe the solution you'd like
swaggerUI := swagger.WrapHandler(swaggerFiles.Handler, swagger.Config{
Oauth2RedirectUrl: "http://localhost:44000",
})
go get github.com/iris-contrib/swagger: no matching versions for query "upgrade"
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.