Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body-parameters Description is not rendered in the HTML document. #565

Open
neillee95 opened this issue Aug 7, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@neillee95
Copy link

neillee95 commented Aug 7, 2023

Your Environment(您的使用环境)

  • smart-doc version: 2.7.4
  • plugin version (e.g. smart-doc-maven-plugin or smart-doc-gradle-plugin): smart-doc-maven-plugin
  • build tool version(maven or gradle): maven

Expected Behavior(您期望的结果)

Body-parameters Description is rendered in the HTML document.
Body-parameters Description 渲染 HTML 文档

Current Behavior(当前结果)

If Body-parameters Description is not rendered in the HTML document, it will display the raw HTML.
Body-parameters Description 不渲染 HTML 文档,会显示原始 HTML

Possible Solution(bug解决建议)

Consistent with the interface description, render HTML.
与接口描述一致,渲染 HTML

Steps to Reproduce (Bug产生步骤,请尽量提供用例代码)

/**
 * Xxx 接口
 */
@RestController
public class XxxController {

    public static class XxxReq {
        /**
         * 唯一标识,应该为以下格式
         * <ul>
         *     <li>111-</li>
         *     <li>222-</li>
         *     <li>333-</li>
         * </ul>
         */
        String id;
    }

    public static class XxxResp {
        String id;
    }

    /**
     * Xxx 接口
     * @apiNote 该接口用来 .....,详情查看 <a href="#">xxxxx</a>
     */
    @PostMapping("/xxx")
    public XxxResp handleXxx(@RequestBody XxxReq req) {
        XxxResp resp = new XxxResp();
        resp.id = req.id;
        return resp;
    }

}

The interface description above uses HTML tags, which can be properly rendered in the HTML document.
上面的接口描述中使用了 HTML 标签,在 HTML 文档中能被正常渲染,

image

However, when HTML tags are used in the properties of RequestBody, the generated document cannot be properly rendered and displays the raw HTML.

然而 RequestBody 里的属性使用 HTML 标签,生成的文档却不能被正常渲染,显示的是原始的 HTML,

image

Context(Bug影响描述)

@neillee95 neillee95 added the bug Something isn't working label Aug 7, 2023
@shalousun
Copy link
Collaborator

shalousun commented Aug 7, 2023

@neillee95
If you're interested, you can submit a PR to participate in the co-development.
有兴趣可以提pr参与共建

@neillee95
Copy link
Author

neillee95 commented Aug 10, 2023

There is no problem with the generated document. The issue arises because the HTML was escaped during rendering, causing the HTML tags to be displayed as raw text.

https://github.com/smart-doc-group/smart-doc/blob/b2b9f89b7496071094b997fd9949e4e7d87ce609/src/main/resources/template/html/index.html#L192

In addition to Body-parameters, Query-parameters, Path-parameters, and Request-headers also have their descriptions escaped.
Is it necessary to escape the descriptions of the parameters?
生成的文档没有问题,出现这个问题的原因是渲染时对 HTML 进行了转义,导致 HTML 标签以原文展示,

https://github.com/smart-doc-group/smart-doc/blob/b2b9f89b7496071094b997fd9949e4e7d87ce609/src/main/resources/template/html/index.html#L192

除了 Body-parameters 以外,Query-parameters、Path-parameters、Request-headers 等也对描述做了转义,
是否有必要对参数的描述进行转义?

@shalousun shalousun changed the title Body-parameters Description 不渲染 HTML 文档 Body-parameters Description is not rendered in the HTML document. Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants