-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathauth-summary.html
More file actions
30 lines (28 loc) · 1.03 KB
/
auth-summary.html
File metadata and controls
30 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{{ $operation := .operation }}
{{ $schemes := .schemes | default dict }}
{{ $summary := "" }}
{{ if isset $operation "security" }}
{{ $security := index $operation "security" }}
{{ if not $security }}
{{ $summary = "No authentication required" }}
{{ else }}
{{ $summaries := slice }}
{{ range $security }}
{{ range $schemeName, $scopes := . }}
{{ $itemSummary := replace $schemeName "_" " " | title }}
{{ $scheme := index $schemes $schemeName }}
{{ if and $scheme (eq (lower (index $scheme "type")) "http") (eq (lower (index $scheme "scheme")) "bearer") }}
{{ $itemSummary = "Bearer JWT" }}
{{ end }}
{{ if gt (len $scopes) 0 }}
{{ $itemSummary = printf "%s (%s)" $itemSummary (delimit $scopes ", ") }}
{{ end }}
{{ if not (in $summaries $itemSummary) }}
{{ $summaries = $summaries | append $itemSummary }}
{{ end }}
{{ end }}
{{ end }}
{{ $summary = delimit $summaries " or " }}
{{ end }}
{{ end }}
{{- $summary -}}