Skip to content

Commit

Permalink
Merge pull request #1304 from johnrutherford/multiple-oauth2-schemes
Browse files Browse the repository at this point in the history
Fix duplicate variable name with multiple oauth2 security schemes
  • Loading branch information
tdakkota authored Sep 5, 2024
2 parents eb3c094 + b603d86 commit 8e1b908
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/ex_oauth2/oas_security_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gen/_template/security.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func findAuthorization(h http.Header, prefix string) (string, bool) {

{{ range $s := $.Securities }}
{{- if $s.Format.IsOAuth2Security }}
var oauth2Scopes = map[string][]string {
var oauth2Scopes{{ $s.Type.Name }} = map[string][]string {
{{- range $operationName, $scopes := $s.Scopes }}
{{ quote $operationName }}: []string{
{{- range $scope := $scopes }}
Expand Down Expand Up @@ -99,7 +99,7 @@ func (s *Server) security{{ $s.Type.Name }}(ctx context.Context, operationName s
return ctx, false, nil
}
t.Token = token
t.Scopes = oauth2Scopes[operationName]
t.Scopes = oauth2Scopes{{ $s.Type.Name }}[operationName]
{{- else if $s.Format.IsCustomSecurity }}
t := req
{{- else }}
Expand Down

0 comments on commit 8e1b908

Please sign in to comment.