Git Product home page Git Product logo

knife4g's Introduction

Knife4g

use knife4j-front to show the api documents for gin

Usage

  1. Add comments to your API source code
  2. Download Swag for Go by using:
  3. Run swag init -ot json in your project directory
  4. Run go get github.com/hononet639/knife4g
  5. Add router to your gin project

    example:

    package main
    
    import (
        "github.com/gin-gonic/gin"
        "github.com/hononet639/knife4g"
    )
    
    func main() {
        engine := gin.Default()
        engine.GET("/doc/*any", knife4g.Handler(knife4g.Config{RelativePath: "/doc"}))
        engine.Run(":80")
    }
  6. Visit http://localhost/doc/index

Acknowledgement

Thanks to knife4j

knife4g's People

Contributors

hononet639 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

knife4g's Issues

路径问题

go get之后,
这个函数的./docs/swagger.json相对路径不生效,读出来是nil
func init() {
var err error
docJson, err = os.ReadFile("./docs/swagger.json")
if err != nil {
log.Println("no swagger.json found in ./docs")
}
}

multi module project docs path not found

For a multi module project, run the above command to generate the docs into a sub module. You need to copy to an external module to access it

====== no =======
demo
 ├─srv1
 │   └─main
 │    └─docs
 └─srv2
   └─main

====== ok =======

demo
 ├─srv1
 │  └─main
 ├─srv2
 │  └─main
 └─docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.