【发布时间】:2017-02-15 13:36:27
【问题描述】:
我正在尝试为 go implementation of petstore example 创建规范文件。我在具有doc.go 的目录中尝试了go generate,但它什么也没做。进一步阅读,我意识到应该有
//go:generate swagger generate spec -o swagger.json
在doc.go 中。当我添加它创建一个规范文件但它不包含整个规范时。这是在go generate 上创建的 .json 文件
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "the purpose of this application is to provide an application\nthat is using plain go code to define an API\n\nThis should demonstrate all the possible comment annotations\nthat are available to turn go code into a fully compliant swagger 2.0 spec",
"title": "Petstore API.",
"termsOfService": "there are no TOS at this moment, use at your own risk we take no responsibility\ngo:generate swagger generate spec -o swagger.json",
"contact": {
"name": "John Doe",
"url": "http://john.doe.com",
"email": "john.doe@example.com"
},
"license": {
"name": "MIT",
"url": "http://opensource.org/licenses/MIT"
},
"version": "0.0.1"
},
"host": "localhost",
"basePath": "/v2",
"paths": {}
}
spec 文件中没有提到路由/参数/模型。这是应该的吗?这是来自 goswagger repo 的官方示例,所以我怀疑代码是错误的。我应该改变什么才能让它工作?
【问题讨论】:
标签: go swagger go-swagger