Skip to content

Commit

Permalink
feat: add default description to code if none is provided (#1239)
Browse files Browse the repository at this point in the history
Co-authored-by: chengjin <chengjin@cmiot.chinamobile.com>
  • Loading branch information
sdghchj and chengjin committed Jun 27, 2022
1 parent 0e2ec6c commit a566490
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion operation.go
Expand Up @@ -1130,7 +1130,7 @@ func (operation *Operation) ParseEmptyResponseOnly(commentLine string) error {
return fmt.Errorf("can not parse response comment \"%s\"", commentLine)
}

operation.AddResponse(code, spec.NewResponse())
operation.AddResponse(code, spec.NewResponse().WithDescription(http.StatusText(code)))
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions operation_test.go
Expand Up @@ -1071,7 +1071,7 @@ func TestParseEmptyResponseOnlyCode(t *testing.T) {
expected := `{
"responses": {
"200": {
"description": ""
"description": "OK"
}
}
}`
Expand All @@ -1091,10 +1091,10 @@ func TestParseEmptyResponseOnlyCodes(t *testing.T) {
expected := `{
"responses": {
"200": {
"description": ""
"description": "OK"
},
"201": {
"description": ""
"description": "Created"
},
"default": {
"description": ""
Expand Down
6 changes: 3 additions & 3 deletions parser_test.go
Expand Up @@ -3105,7 +3105,7 @@ func Fun() {
],
"responses": {
"200": {
"description": ""
"description": "OK"
}
}
}
Expand Down Expand Up @@ -3162,7 +3162,7 @@ func Fun() {
],
"responses": {
"200": {
"description": ""
"description": "OK"
}
}
}
Expand Down Expand Up @@ -3326,7 +3326,7 @@ func TestParseJSONFieldString(t *testing.T) {
}
},
"500": {
"description": ""
"description": "Internal Server Error"
}
}
}
Expand Down

0 comments on commit a566490

Please sign in to comment.