Skip to content

Commit

Permalink
Added multiline support for @description attribute for securityDefini…
Browse files Browse the repository at this point in the history
…tions (#1786)
  • Loading branch information
golandprog authored Apr 22, 2024
1 parent 4c2f8dd commit 85254b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,10 @@ loopline:

// Not mandatory field
if securityAttr == descriptionAttr {
description = value
if description != "" {
description += "\n"
}
description += value
}

// next securityDefinitions
Expand Down
18 changes: 18 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 85254b4

Please sign in to comment.