Skip to main content

[pkg] Go Swagger 筆記

go swagger


使用 homebrew 安裝:

$ brew tap go-swagger/go-swagger
$ brew install go-swagger

Generate Spec from source#

Generate spec from source

根據程式碼中的註解產生對應的 swagger 文件。在專案根目錄下執行:

# 在專案中產生 swagger.yaml
$ swagger generate spec -o ./swagger.yaml


swagger:meta 後面一定要直接接 package foobar 中間不能有空行:

// Package classification Book API.
// The purpose of this service is to provide an application
// that is using plain go code to define an API
// Host: localhost
// Version: 0.0.1
// swagger:meta
package book
Last updated on