-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
The strict-interface template currently treats all response headers as required. However, it should be possible to omit optional headers.
Possible template changes could be:
type {{$opid}}{{$statusCode}}ResponseHeaders struct {
{{range .Headers -}}
+ {{if .Schema.OAPISchema.Nullable -}}
+ {{.GoName}} nullable.Nullable[{{.Schema.TypeDecl}}]
+ {{else -}}
{{.GoName}} {{.Schema.TypeDecl}}
+ {{end -}}
{{end -}}
}and:
{{range $headers -}}
+ {{if .Schema.OAPISchema.Nullable -}}
+ if val, err := response.Headers.{{.GoName}}.Get(); err == nil {
+ w.Header().Set("{{.Name}}", fmt.Sprint(val))
+ }
+ {{else -}}
w.Header().Set("{{.Name}}", fmt.Sprint(response.Headers.{{.GoName}}))
+ {{end -}}
{{end -}}Maybe it might also make sense respecting the pointers vs. nullable setting and using pointers accordingly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels