Coder Social home page Coder Social logo

andeya / swagger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yvasiyarov/swagger

1.0 2.0 0.0 1.27 MB

Swagger client generator

License: BSD 3-Clause "New" or "Revised" License

Go 22.44% Shell 0.08% CSS 9.37% HTML 0.85% JavaScript 67.26%

swagger's Introduction

alt text

##Swagger UI Generator for Go

###About

This is a utility for automatically generating API documentation from annotations in Go code. It generates the documentation as JSON, according to the Swagger Spec, and then displays it using Swagger UI.

This tool was inspired by Beego, and follows the same annotation standards set by Beego. The main difference between this tool and Beego is that this generator doesn't depend on the Beego framework. You can use any framework to implement your API (or don't use a framework at all). You just add declarative comments to your API controllers, then run this generator and your documentation is ready! For an example of what such documentation looks like when presented via Swagger UI, see the Swagger pet store example.


####Project Status : Alpha ####Declarative Comments Format : Read more ####Technical Notes : Read More ####Known Limitations : Read More


#### Quick Start Guide
  1. Add comments to your API source code, see Declarative Comments Format

  2. Download Swagger for Go by using go get github.com/yvasiyarov/swagger

  3. Or, compile the Swagger generator from sources. go install

    This will create a binary in your $GOPATH/bin folder called swagger (Mac/Unix) or swagger.exe (Windows).

  4. Run the Swagger generator. Be in the folder with your annotated API source code and run the swagger binary:

    ./$GOPATH/bin/swagger -apiPackage="my_cool_api" -mainApiFile="my_cool_api/web/main.go"

    Command line switches are:

    • -apiPackage - package with API controllers implementation
    • -mainApiFile - main API file. We will look for "General API info" in this file. If the mainApiFile command-line switch is left blank, then main.go is assumed (in the location specified by apiPackage).
    • -format - One of: go|swagger|asciidoc|markdown|confluence. Default is -format="go". See below.
    • -output - Output specification. Default varies according to -format. See below.
    • -controllerClass - Speed up parsing by specifying which receiver objects have the controller methods. The default is to search all methods. The argument can be a regular expression. For example, -controllerClass="(Context|Controller)$" means the receiver name must end in Context or Controller.

You can Generate different formats


  1. To run the generated swagger UI (assuming you used -format="go"), copy/move the generated docs.go file to a new folder under GOPATH/src. Also bring in the web.go-example file, renaming it to web.go. Then: go run web.go docs.go

  2. Enjoy it :-)

swagger's People

Contributors

yvasiyarov avatar polyglot-jones avatar gregzuro avatar robertjgabriel avatar amoghe avatar boonep avatar briannewsom avatar calavera avatar drewwells avatar zasran avatar dorajistyle avatar thekostya avatar mattkanwisher avatar xxxserxxx avatar hmgle avatar mei-rune avatar

Stargazers

 avatar

Watchers

Andeya avatar  avatar

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.