Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以为返回单个值的控制器记录响应字段?
示例: [GET] /book/count
JSON响应: 1
您不能使用响应字段片段。它需要结构化的 JSON 或 XML 响应。鉴于您的响应是一个单一的数值,我认为您不会从 REST Docs 文档中获得太多收益。几乎没有任何东西可以记录和验证。
REST Docs 仍会自动生成您可以使用的 HTTP 响应片段。Snippet如果你想要更多的东西,你可以很容易地编写自己的实现。
Snippet