All Projects → iris-contrib → swagger

iris-contrib / swagger

Licence: MIT license
Iris middleware to automatically generate RESTful API documentation with Swagger 2.0

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to swagger

daany
Daany - .NET DAta ANalYtics .NET library with the implementation of DataFrame, Time series decompositions and Linear Algebra routines BLASS and LAPACK.
Stars: ✭ 49 (-45.56%)
Mutual labels:  iris
iris
Repositório oficial da BOT Íris, uma robô em português, inglês e espanhol para WhatsApp [Com MD/Sem MD], possui centenas de comandos diferentes, a lista vai de fazer stickers a jogar xadrez ou blackjack.
Stars: ✭ 166 (+84.44%)
Mutual labels:  iris
iris-simp-lang
We define a simple programming language, simp_lang, then instantiate Iris to verify simple simp_lang programs with concurrent separation logic.
Stars: ✭ 40 (-55.56%)
Mutual labels:  iris
demo-chatroom
go+iris+jwt+mysql+xorm+viper,iris项目实战简易聊天室,登录、注册、私聊、群聊。
Stars: ✭ 47 (-47.78%)
Mutual labels:  iris
server-benchmarks
🚀 Cross-platform transparent benchmarks for HTTP/2 Web Servers at 2020-2023
Stars: ✭ 78 (-13.33%)
Mutual labels:  iris
Iris
The fastest HTTP/2 Go Web Framework. AWS Lambda, gRPC, MVC, Unique Router, Websockets, Sessions, Test suite, Dependency Injection and more. A true successor of expressjs and laravel | 谢谢 https://github.com/kataras/iris/issues/1329 |
Stars: ✭ 21,587 (+23885.56%)
Mutual labels:  iris
IRIS
📚A Multi-Nomial Classification of Iris Dataset.
Stars: ✭ 15 (-83.33%)
Mutual labels:  iris
cosmostation-ios
👽 Cosmostation iOS Wallet
Stars: ✭ 14 (-84.44%)
Mutual labels:  iris
extra keras datasets
📃🎉 Additional datasets for tensorflow.keras
Stars: ✭ 20 (-77.78%)
Mutual labels:  iris
jeelizPupillometry
Real-time pupillometry in the web browser using a 4K webcam video feed processed by this WebGL/Javascript library. 2 demo experiments are included.
Stars: ✭ 78 (-13.33%)
Mutual labels:  iris
iris-admin
Web admin for iris-go framwork
Stars: ✭ 602 (+568.89%)
Mutual labels:  iris
mir
Mir is a toolkit for register method handler to http engine router(eg: gin,echo,iris,mux,httprouter) use struct tag info.
Stars: ✭ 42 (-53.33%)
Mutual labels:  iris
dujt
毒鸡汤 - 壮士可要来一碗!
Stars: ✭ 15 (-83.33%)
Mutual labels:  iris
tonovel-go
tonovel是一个简洁,干净的小说聚合系统
Stars: ✭ 70 (-22.22%)
Mutual labels:  iris
go-tenancy
快速实现 SaaS 多租户平台项目
Stars: ✭ 157 (+74.44%)
Mutual labels:  iris
sunraster
A SunPy-affiliated package which provides tools to analyze data from spectral data from any solar mission.
Stars: ✭ 19 (-78.89%)
Mutual labels:  iris
iris-gorm-demo
iris+gorm+mysql的restful api项目起手式
Stars: ✭ 92 (+2.22%)
Mutual labels:  iris
web-marisa
🍄 白丝魔理沙网页版
Stars: ✭ 65 (-27.78%)
Mutual labels:  iris
Machine-Learning-Notebooks
15+ Machine/Deep Learning Projects in Ipython Notebooks
Stars: ✭ 66 (-26.67%)
Mutual labels:  iris

Swagger for the Iris web framework

Iris middleware to automatically generate RESTful API documentation with Swagger 2.0 as requested at #1231.

build status Go Report Card

Usage

Start using it

  1. Add comments to your API source code, See Declarative Comments Format.
  2. Download Swag for Go by using:
$ go install github.com/swaggo/swag/cmd/swag@latest
  1. Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
$ swag init
  1. Download swagger for Iris by using:
$ go get github.com/iris-contrib/swagger/v12@master

And import following in your code:

import "github.com/iris-contrib/swagger/v12" // swagger middleware for Iris 
import "github.com/iris-contrib/swagger/v12/swaggerFiles" // swagger embed files

Example Code:

package main

import (
    "github.com/kataras/iris/v12"

    "github.com/iris-contrib/swagger/v12"
    "github.com/iris-contrib/swagger/v12/swaggerFiles"

    _ "github.com/your_username/your_project/docs"
    // docs folder should be generated by Swag CLI (swag init),
    // 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 localhost:8080
// @BasePath /v2
func main() {
    app := iris.New()

    config := swagger.Config{
        // The url pointing to API definition.
        URL:          "http://localhost:8080/swagger/doc.json",
        DeepLinking:  true,
        DocExpansion: "list",
        DomID:        "#swagger-ui",
        // The UI prefix URL (see route).
        Prefix:       "/swagger",
    }
    swaggerUI := swagger.Handler(swaggerFiles.Handler, config)

    // Register on http://localhost:8080/swagger
    app.Get("/swagger", swaggerUI)
    // And the wildcard one for index.html, *.js, *.css and e.t.c.
    app.Get("/swagger/{any:path}", swaggerUI)

    app.Listen(":8080")
}
  1. Run it, and navigate through http://localhost:8080/swagger/index.html, you should see the Swagger 2.0 API documentation page.

  2. If you want to disable swagger when some environment variable is set, use DisablingHandler instead of Handler.

swagger.DisablingHandler(swaggerFiles.Handler, "THE_OS_VARIABLE_NAME_HERE", config)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].