void 操作需要 'produces' assertj-swagger 中的 swagger 定义
void operation requires 'produces' swagger definition in assertj-swagger
我有以下 Spring 引导 (1.3.1) @RestController
定义:
@RequestMapping(value = "/blah", method = DELETE)
@ResponseStatus(NO_CONTENT)
public void blah() {...}
并且正在使用 assertj-swagger
根据以下 swagger 规范验证以上内容:
'/blah':
delete:
已实施操作的验证(断言)失败,原因如下:
[Checking 'produces' of 'DELETE' operation of path '/blah']
Expecting null or empty but was:<["*/*"]>
但我不明白为什么 produces
MediaType.ALL
是我们试图用 Swagger 描述的 void
方法?
如有任何想法,我们将不胜感激,将其添加到我们所有记录的 API 中似乎无关紧要...
感谢和问候。
Http 是 a request/response protocol。所以即使你的操作returns一个void,仍然有一个http响应;即使它的 Content-Length
为 0(无效)。这就是它建模为 MediaType.ALL
(读取任何媒体类型或没有特定媒体类型)
的原因
我有以下 Spring 引导 (1.3.1) @RestController
定义:
@RequestMapping(value = "/blah", method = DELETE)
@ResponseStatus(NO_CONTENT)
public void blah() {...}
并且正在使用 assertj-swagger
根据以下 swagger 规范验证以上内容:
'/blah':
delete:
已实施操作的验证(断言)失败,原因如下:
[Checking 'produces' of 'DELETE' operation of path '/blah']
Expecting null or empty but was:<["*/*"]>
但我不明白为什么 produces
MediaType.ALL
是我们试图用 Swagger 描述的 void
方法?
如有任何想法,我们将不胜感激,将其添加到我们所有记录的 API 中似乎无关紧要...
感谢和问候。
Http 是 a request/response protocol。所以即使你的操作returns一个void,仍然有一个http响应;即使它的 Content-Length
为 0(无效)。这就是它建模为 MediaType.ALL
(读取任何媒体类型或没有特定媒体类型)