我创建了一个产生“应用程序/压缩包”的招摇规范
/config:
get:
produces:
- application/zip
responses:
200: # OK
description: All config files
schema:
type: string
format: binary
我已经为这个端点实现了处理程序,但我收到了这个错误
http: panic serving 127.0.0.1:20366: applicationZip producer has not yet been implemented
此错误来自此代码
func NewSampleAPI(spec *loads.Document) *SampleAPI {
return &SampleAPI{
...
ApplicationZipProducer: runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
return errors.NotImplemented("applicationZip producer has not yet been implemented")
}),
在调查了这个错误之后,我的发现是我们需要实现这样的东西
api := operations.NewSampleAPI(swaggerSpec)
api.ApplicationZipProducer = func(w io.Writer, data interface{}) error {
...
}
所以我的问题是
我们应该在这个 Producer 中放入什么,为什么有必要实现它,因为“application/json”没有实现?
“application/json”Producer是默认实现的,我们需要实现其他Producer吗?
注意:我使用的是 swagger "2.0" 规范