spring-restdocs 如何从路径参数中删除表名



我正在记录我的 API 的路径参数。但它显示一些自动生成的表名。我正在尝试从路径参数中删除表名.我没有成功。

请帮帮我。

示例图像

如果只想删除表格标题的"表 2"部分,可以尝试添加标题为空的标题块。例如:

[caption=]
./v1/residences/{id}
include::{snippets}/index/request-parameters.adoc[]

最好的方法是将@jmformenti和@alek的答案结合起来:

  1. src/test/resources/org/springframework/restdocs/templates/asciidoctor/中创建文件path-parameters.snippet
  2. 使用此模板内容:
[caption=]
.{{path}}
|===
|Parameter|Description
{{#parameters}}
|{{#tableCellContent}}`+{{name}}+`{{/tableCellContent}}
|{{#tableCellContent}}{{description}}{{/tableCellContent}}
{{/parameters}}
|===

现在,所有生成的path-parameters.adoc文件都将具有正确的内容,您无需像 Alek 的答案那样为每个包含添加它。

您必须自定义路径参数片段:

  1. 在项目中添加新的代码段模板 src/test/resources/org/springframework/restdocs/templates/asciidoctor/path-parameters.snippet
  2. 模板内容:
+{{路径}}+|===|参数|描述{{#parameters}}|{{#tableCellContent}}'+{{name}}+'{{/tableCellContent}}|{{#tableCellContent}}{{描述}}{{/tableCellContent}}{{/参数}}|===

最新更新