Skip to content

Commit bd9ecc2

Browse files
committed
fix lint warning and revert nil slice handling
1 parent 81968c5 commit bd9ecc2

3 files changed

Lines changed: 2 additions & 20 deletions

File tree

pkg/codegen/operations.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,6 @@ func (r ResponseContentDefinition) IsJSON() bool {
511511
return util.IsMediaTypeJson(r.ContentType)
512512
}
513513

514-
// __BEGIN_CYLONIX_MOD__
515-
// IsArray returns whether this is an array type response.
516-
func (r ResponseContentDefinition) IsArray() bool {
517-
return r.Schema.ArrayType != nil ||
518-
(r.Schema.OAPISchema != nil && r.Schema.OAPISchema.Type != nil &&
519-
r.Schema.OAPISchema.Type.Is("array"))
520-
}
521-
// __END_CYLONIX_MOD__
522-
523514
type ResponseHeaderDefinition struct {
524515
Name string
525516
GoName string

pkg/codegen/templates/strict/strict-http.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ type strictHandler struct {
2727
options StrictHTTPServerOptions
2828
}
2929

30-
const SecurityAuthContextKey = "Secutiry-Auth"
30+
type StrictHTTPContextKeyType string
31+
const SecurityAuthContextKey = StrictHTTPContextKeyType("Secutiry-Auth")
3132

3233
{{range .}}
3334
{{$opid := .OperationId}}

pkg/codegen/templates/strict/strict-interface.tmpl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@
8989
{{$hasBodyVar := or ($hasHeaders) (not $fixedStatusCode) (not .IsSupported)}}
9090
{{if .IsJSON -}}
9191
{{$hasUnionElements := ne 0 (len .Schema.UnionElements)}}
92-
{{/* __BEGIN_CYLONIX_MOD__ */}}
93-
{{/* Workaround for golang json encoding nil slice or array to 'null' value: */}}
94-
{{/* https://github.com/golang/go/issues/27589 */}}
95-
{{/* */}}
96-
{{if .IsArray -}}
97-
if response == nil {
98-
response = {{$receiverTypeName}}{}
99-
}
100-
{{end -}}
101-
{{/* __END_CYLONIX_MOD__ */}}
10292
return json.NewEncoder(w).Encode(response{{if $hasBodyVar}}.Body{{end}}{{if $hasUnionElements}}.union{{end}})
10393
{{else if eq .NameTag "Text" -}}
10494
_, err := w.Write([]byte({{if $hasBodyVar}}response.Body{{else}}response{{end}}))

0 commit comments

Comments
 (0)