diff --git a/parser.go b/parser.go index 561c4549e..8a47d0046 100644 --- a/parser.go +++ b/parser.go @@ -774,7 +774,10 @@ loopline: // Not mandatory field if securityAttr == descriptionAttr { - description = value + if description != "" { + description += "\n" + } + description += value } // next securityDefinitions diff --git a/parser_test.go b/parser_test.go index 7862796d1..0479a7595 100644 --- a/parser_test.go +++ b/parser_test.go @@ -3864,6 +3864,24 @@ func TestTryAddDescription(t *testing.T) { }, }, }, + { + name: "added description with multiline", + lines: []string{ + "\t@securitydefinitions.apikey test", + "\t@in header", + "\t@name x-api-key", + "\t@description line1", + "\t@description line2", + }, + want: &spec.SecurityScheme{ + SecuritySchemeProps: spec.SecuritySchemeProps{ + Name: "x-api-key", + Type: "apiKey", + In: "header", + Description: "line1\nline2", + }, + }, + }, { name: "no description", lines: []string{