I am trying to create a spec file for the go implementation of petstore example . I tried a go generate
in the directory which had doc.go
but it did nothing. On further reading, I realised that there should be
//go:generate swagger generate spec -o swagger.json
in doc.go
. When I added that it creates a spec file but it doesn't contain the entire specification. This is the .json file that is create on go generate
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "the purpose of this application is to provide an application
that is using plain go code to define an API
This should demonstrate all the possible comment annotations
that 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
go: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": {}
}
There are no routes/parameters/models mentioned in the spec file. Is this how this is supposed to be? This is an official example from the goswagger repo so I doubt the code is wrong. What should I change to make it work?