【发布时间】:2020-10-24 18:58:31
【问题描述】:
我正在尝试使用从我的 API 处理程序生成 swagger 规范。
我已经从go get安装了go-swagger:
go get -u github.com/go-swagger/go-swagger/cmd/swagger
请看下面的项目结构:
main.go 使用products.go 中的处理程序定义。 (API 工作并经过测试)
product.go 中的 Swagger 规范:
// Package classification of Product API.
//
// Documenting for Product API
//
//
//
// Schemes: http, https
// BasePath: /
// Version: 0.0.1
//
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// swagger:meta
从main.go 路径运行以下命令:
GO111MODULE=off swagger generate spec -o ./swagger.yaml --scan-models
回复:
info: {}
paths: {}
swagger: "2.0"
预期响应:
basePath: /
consumes:
- application/json
info:
description: Documenting for Product API
title:
version: 0.0.1
paths: {}
producrs:
- application/json
schemes:
- http
swagger: "2.0"
【问题讨论】:
标签: go swagger go-swagger