Skip to content

Commit

Permalink
[securityOr] fix simpleTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Schenkelchlopfer committed Mar 8, 2022
1 parent 4b990b5 commit 750be1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions operation.go
Expand Up @@ -631,7 +631,9 @@ func (operation *Operation) ParseRouterComment(commentLine string) error {

// ParseSecurityComment parses comment for given `security` comment string.
func (operation *Operation) ParseSecurityComment(commentLine string) error {
var securityMap map[string][]string = map[string][]string{}
//var securityMap map[string][]string = map[string][]string{}

var securityMap = make(map[string][]string)
securitySource := commentLine[strings.Index(commentLine, "@Security")+1:]
for _, securityOption := range strings.Split(securitySource, "||") {
securityOption = strings.TrimSpace(securityOption)
Expand All @@ -648,7 +650,6 @@ func (operation *Operation) ParseSecurityComment(commentLine string) error {

} else {
securityKey := strings.TrimSpace(securityOption)
securityMap := map[string][]string{}
securityMap[securityKey] = []string{}
}
}
Expand Down
16 changes: 16 additions & 0 deletions operation_test.go
Expand Up @@ -2036,6 +2036,22 @@ func TestParseSecurityComment(t *testing.T) {
})
}

func TestParseSecurityCommentSimple(t *testing.T) {
t.Parallel()

comment := `@Security ApiKeyAuth`
operation := NewOperation(nil)

err := operation.ParseComment(comment, nil)
assert.NoError(t, err)

assert.Equal(t, operation.Security, []map[string][]string{
{
"ApiKeyAuth": {},
},
})
}

func TestParseSecurityCommentOr(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 750be1e

Please sign in to comment.