使用其余文档,我定义了以下参数:
RequestPartsSnippet parts = requestParts(
partWithName("name").description("The name of the service. Example: <pre> some json </pre>")
);
然后我在测试中以这种方式调用该服务:
Response response = target
.register(documentationConfiguration(doc))
.register(document("department-200",
preprocessRequest(removeUserAgent, Preprocessors.prettyPrint()),
preprocessResponse(Preprocessors.prettyPrint()),
requestParameters(desc),
parts))
.request()
.header("Authorization", admin)
.post(Entity.entity(multi, multi.getMediaType()));
这是相关的 adoc 文件行:
.request-fields
include::{snippets}/department-200/request-parts.adoc[]
我希望参数描述中的 json 使用标签 pre 进行格式化。但是,该标记会转换为其等效的 html 符号。
我需要更改什么才能使 json 格式正确地输入到我的浏览器中?
最佳答案
您应该在描述中使用 Asciidoc 格式而不是 HTML。例如,您可以用单反引号包围 JSON。
关于java - Spring Rest 文档不处理 html 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49135513/