Skip to content

Commit 85254b4

Browse files
authored
Added multiline support for @description attribute for securityDefinitions (#1786)
1 parent 4c2f8dd commit 85254b4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

parser.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,10 @@ loopline:
774774

775775
// Not mandatory field
776776
if securityAttr == descriptionAttr {
777-
description = value
777+
if description != "" {
778+
description += "\n"
779+
}
780+
description += value
778781
}
779782

780783
// next securityDefinitions

parser_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,24 @@ func TestTryAddDescription(t *testing.T) {
38643864
},
38653865
},
38663866
},
3867+
{
3868+
name: "added description with multiline",
3869+
lines: []string{
3870+
"\t@securitydefinitions.apikey test",
3871+
"\t@in header",
3872+
"\t@name x-api-key",
3873+
"\t@description line1",
3874+
"\t@description line2",
3875+
},
3876+
want: &spec.SecurityScheme{
3877+
SecuritySchemeProps: spec.SecuritySchemeProps{
3878+
Name: "x-api-key",
3879+
Type: "apiKey",
3880+
In: "header",
3881+
Description: "line1\nline2",
3882+
},
3883+
},
3884+
},
38673885
{
38683886
name: "no description",
38693887
lines: []string{

0 commit comments

Comments
 (0)