简体   繁体   English

Spring rest 文档不处理 html 标签

[英]Spring rest docs not processing html tags

Using rest docs, I define the following parameter:使用rest docs,我定义了以下参数:

RequestPartsSnippet parts = requestParts(
            partWithName("name").description("The name of the service. Example: <pre> some json </pre>")
 );

Then I call the service in that way in my tests:然后我在测试中以这种方式调用服务:

    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()));

Here's the related adoc file line:这是相关的 adoc 文件行:

.request-fields
include::{snippets}/department-200/request-parts.adoc[]

I would expect the json in the parameter description to be formatted with the tag pre.我希望参数描述中的 json 使用标签 pre 进行格式化。 However the tag is converted into its html symbol equivalent.然而,标签被转换为其等效的 html 符号。

What I need to change to have the json correctly formatted into my browser?我需要更改什么才能将 json 正确格式化到我的浏览器中?

You should use Asciidoc formatting in the description rather than HTML.您应该在描述中使用 Asciidoc 格式而不是 HTML。 For example, you could surround the JSON with single back ticks.例如,您可以用单个反勾号将 JSON 括起来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM