Skip to content

Commit

Permalink
refactor(openapi): MarkdownProblems 删除已经无用的 detail 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Dec 2, 2024
1 parent d8a158d commit d02756e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions openapi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func getPathParams(path string) []string {
// titleLevel 标题的级别,0-6:
// 如果取值为 0,表示以列表的形式输出,并忽略 detail 字段的内容。
// 1-6 表示输出 detail 内容,并且将 type 和 title 作为标题;
func MarkdownProblems(s web.Server, titleLevel int, detail bool) web.LocaleStringer {
if detail {
func MarkdownProblems(s web.Server, titleLevel int) web.LocaleStringer {
if titleLevel != 0 {
return markdownProblemsWithDetail(s, titleLevel)
} else {
return markdownProblemsWithoutDetail(s)
Expand Down
4 changes: 2 additions & 2 deletions openapi/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func TestMarkdownProblems(t *testing.T) {
ss := newServer(a)
p := ss.Locale().NewPrinter(language.SimplifiedChinese)

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

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

0 comments on commit d02756e

Please sign in to comment.