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

add default description to code if none is provided #1239

Merged
merged 1 commit into from Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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