From 96b9a5511aea4b74d21cbfd60eedb265e91eac5d Mon Sep 17 00:00:00 2001 From: chengjin Date: Fri, 24 Jun 2022 10:43:48 +0800 Subject: [PATCH] add default description to code if none is provided --- operation.go | 2 +- operation_test.go | 6 +++--- parser_test.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/operation.go b/operation.go index 20e7cefc5..29e6bf429 100644 --- a/operation.go +++ b/operation.go @@ -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 diff --git a/operation_test.go b/operation_test.go index d8089f0a2..d10f5da07 100644 --- a/operation_test.go +++ b/operation_test.go @@ -1071,7 +1071,7 @@ func TestParseEmptyResponseOnlyCode(t *testing.T) { expected := `{ "responses": { "200": { - "description": "" + "description": "OK" } } }` @@ -1091,10 +1091,10 @@ func TestParseEmptyResponseOnlyCodes(t *testing.T) { expected := `{ "responses": { "200": { - "description": "" + "description": "OK" }, "201": { - "description": "" + "description": "Created" }, "default": { "description": "" diff --git a/parser_test.go b/parser_test.go index 87c9099ab..1a8b5b06f 100644 --- a/parser_test.go +++ b/parser_test.go @@ -3105,7 +3105,7 @@ func Fun() { ], "responses": { "200": { - "description": "" + "description": "OK" } } } @@ -3162,7 +3162,7 @@ func Fun() { ], "responses": { "200": { - "description": "" + "description": "OK" } } } @@ -3326,7 +3326,7 @@ func TestParseJSONFieldString(t *testing.T) { } }, "500": { - "description": "" + "description": "Internal Server Error" } } }