V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
LeslieLeung
0.66D

写了个给 gin 项目生成 swagger.json 并自动上传到 yapi 的小工具

  •  
  •   LeslieLeung · Nov 19, 2022 · 2120 views
    This topic created in 1261 days ago, the information mentioned may be changed or developed.

    最近因为跟客户端联调的时候写错了一个字段的类型,扯皮了很久。为了避免后续再扯皮,写了个从 gin 项目导出 swagger (底层是 swaggo/swag)并上传到 yapi 的小工具。

    安装

    go install

    go install github.com/leslieleung/yaag@latest
    

    快速开始

    在项目目录下创建一个 yaag.yaml

    可以将 example/yaag.yaml 复制到项目根目录,或者使用 yaag -init 来创建一个。

    填写 yaag.yaml

    docDir: "" # swagger.json 生成目录
    mergeMode: "" # Yapi 合并模式, 见 http://yapi.smart-xwork.cn/doc/openapi.html
    swagGeneral: "" # API 基础信息注解的目录, 默认为 main.go
    yapiUrl: "" # Yapi 的 url
    yapiToken: "" # Yapi 项目的 token
    

    安装 swag 并写注解

    go install github.com/swaggo/swag/cmd/swag@latest
    

    更多详情请参考 swaggo/swag

    运行 yaag

    项目地址 https://github.com/LeslieLeung/yaag 欢迎 star 。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2582 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:58 · PVG 22:58 · LAX 07:58 · JFK 10:58
    ♥ Do have faith in what you're doing.