Giter Site home page Giter Site logo

onecodemonkey / apidoc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caixw/apidoc

0.0 3.0 0.0 1.41 MB

RESTful API 文档生成工具,支持 Go、Java、Swift、JavaScript、Rust、PHP、Python 和 Ruby 等大部分语言。

Home Page: https://apidoc.tools

License: MIT License

Go 94.73% C++ 1.85% Rust 2.40% Batchfile 0.59% Shell 0.43%

apidoc's Introduction

apidoc Build Status Go version Go Report Card license codecov

apidoc 是一个简单的 RESTful API 文档生成工具,它从代码注释中提取特定格式的内容,生成文档。 目前支持支持以下语言:C#、C/C++、D、Erlang、Go、Groovy、Java、JavaScript、Pascal/Delphi、 Perl、PHP、Python、Ruby、Rust、Scala 和 Swift。

具体文档可参考:https://apidoc.tools

/**
 * @api get /users 获取所有的用户信息
 * @apiTags users
 * @apiQuery page int 显示第几页的内容
 * @apiQuery size int 每页显示的数量
 *
 * @apiResponse 200 object application/json ok
 * @apiParam count int required 符合条件的所有用户数量
 * @apiParam users array.object required 用户列表。
 * @apiExample application/json
 * {
 *     "count": 500,
 *     "users": [
 *         {"id":1, "username": "admin1", "name": "管理员2"},
 *         {"id":2, "username": "admin2", "name": "管理员2"}
 *     ],
 * }
 * @apiExample application/xml
 * <users count="500">
 *     <user id="1" username="admin1" name="管理员1" />
 *     <user id="2" username="admin2" name="管理员2" />
 * </users>
 */
func login(w http.ResponseWriter, r *http.Request) {
    // TODO
}

安装

go get github.com/caixw/apidoc

支持多种本地化语言,默认情况下会根据当前系统所使用的语言进行调整。若需要手动指定, windows 可以设置一个 LANG 环境变量指定,*nix 系统可以使用以下命令:

LANG=lang apidoc

将其中的 lang 设置为你需要的语言。

集成

若需要将 apidoc 当作包集成到其它 Go 程序中,可参考以下代码:

// 初始本地化内容
apidoc.InitLocale()

// 可以自定义实现具体的错误处理方式
h := errors.NewHandler()

erro := log.NewLogger()
output := &output.Options{...}
inputs := []*input.Options{
    &input.Options{},
}

apidoc.Do(h, output, inputs...)

参与开发

请阅读 CONTRIBUTING.md 文件的相关内容。

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

apidoc's People

Contributors

caixw avatar xuanwo avatar

Watchers

 avatar  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.