Skip to content

Commit

Permalink
fix: allows server variable enum to be unset
Browse files Browse the repository at this point in the history
  • Loading branch information
atombender committed Jul 1, 2024
1 parent 01e42b7 commit 8aa1de4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gen/_template/servers.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s {{ $s.Name }}) Build() (string, error) {
}
{{- range $p := $s.Params }}
s.{{ $p.Name }} = zeroOr(s.{{ $p.Name }}, {{ quote $p.Spec.Default }})
{{- if $p.Spec.Enum }}
// Validate {{ quote $p.Spec.Name }}
switch s.{{ $p.Name }} {
{{- range $e := $p.Spec.Enum }}
Expand All @@ -59,6 +60,7 @@ func (s {{ $s.Name }}) Build() (string, error) {
return "", errors.Errorf("param %q: unexpected value %q", {{ quote $p.Spec.Name }}, s.{{ $p.Name }})
}
{{- end }}
{{- end }}
return fmt.Sprintf({{ $s.FormatString | quote }},
{{- range $p := $s.Params }}
s.{{ $p.Name }},
Expand Down

0 comments on commit 8aa1de4

Please sign in to comment.