diff --git a/operation.go b/operation.go index ac79e3102..2ce9c9e4d 100644 --- a/operation.go +++ b/operation.go @@ -281,7 +281,7 @@ func (operation *Operation) ParseParamComment(commentLine string, astFile *ast.F requiredText := strings.ToLower(matches[4]) required := requiredText == "true" || requiredText == requiredLabel - description := matches[5] + description := strings.Join(strings.Split(matches[5], "\\n"), "\n") param := createParameter(paramType, description, name, objectType, refType, required, enums, operation.parser.collectionFormatInQuery) diff --git a/operation_test.go b/operation_test.go index 50e4ac3b1..9ce46982f 100644 --- a/operation_test.go +++ b/operation_test.go @@ -1322,6 +1322,27 @@ func TestParseParamCommentByID(t *testing.T) { assert.Equal(t, expected, string(b)) } +func TestParseParamCommentWithMultilineDescriptions(t *testing.T) { + t.Parallel() + + comment := `@Param some_id query int true "First line\nSecond line\nThird line"` + operation := NewOperation(nil) + err := operation.ParseComment(comment, nil) + + assert.NoError(t, err) + b, _ := json.MarshalIndent(operation.Parameters, "", " ") + expected := `[ + { + "type": "integer", + "description": "First line\nSecond line\nThird line", + "name": "some_id", + "in": "query", + "required": true + } +]` + assert.Equal(t, expected, string(b)) +} + func TestParseParamCommentByQueryType(t *testing.T) { t.Parallel()