openapi extension to the go-restful package, OpenAPI-Specification version 2.0
use it to replace go-restful-swagger12
config := swagger.Config{ WebServices: restful.DefaultContainer.RegisteredWebServices(), FileStyle:"json", //optional, default is yaml OpenService: true, //should show it in rest API service WebServicesUrl: "http://localhost:8080", ApiPath: "/apidocs.json", //swagger doc api path OutFilePath: os.Getenv("SWAGGERFILEPATH"), } swagger.RegisterSwaggerService(config, restful.DefaultContainer)go struct
type X struct { A int B int `json:"C"` //Will generate C here D int `json:"-"` //Will ignore it }result
"X": { "type": "object", "properties": { "A": { "type": "integer", "format": "int32" }, "C": { "type": "integer", "format": "int32" } } }