Skip to content

Commit d02756e

Browse files
committed
refactor(openapi): MarkdownProblems 删除已经无用的 detail 参数
1 parent d8a158d commit d02756e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

openapi/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ func getPathParams(path string) []string {
9999
// titleLevel 标题的级别,0-6:
100100
// 如果取值为 0,表示以列表的形式输出,并忽略 detail 字段的内容。
101101
// 1-6 表示输出 detail 内容,并且将 type 和 title 作为标题;
102-
func MarkdownProblems(s web.Server, titleLevel int, detail bool) web.LocaleStringer {
103-
if detail {
102+
func MarkdownProblems(s web.Server, titleLevel int) web.LocaleStringer {
103+
if titleLevel != 0 {
104104
return markdownProblemsWithDetail(s, titleLevel)
105105
} else {
106106
return markdownProblemsWithoutDetail(s)

openapi/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ func TestMarkdownProblems(t *testing.T) {
5454
ss := newServer(a)
5555
p := ss.Locale().NewPrinter(language.SimplifiedChinese)
5656

57-
txt := MarkdownProblems(ss, 2, true)
57+
txt := MarkdownProblems(ss, 2)
5858
lines := strings.Split(txt.LocaleString(p), "\n\n")
5959
a.Equal(lines[0], "## 400 Bad Request").
6060
Equal(lines[1], "表示客户端错误,比如,错误的请求语法、无效的请求消息帧或欺骗性的请求路由等,服务器无法或不会处理该请求。").
6161
Equal(lines[2], "## 401 Unauthorized")
6262

63-
txt = MarkdownProblems(ss, 3, false)
63+
txt = MarkdownProblems(ss, 0)
6464
lines = strings.Split(txt.LocaleString(p), "\n\n")
6565
a.Equal(lines[0], "- 400: Bad Request").
6666
Equal(lines[1], "- 401: Unauthorized")

0 commit comments

Comments
 (0)