diff --git a/go-runtime/compile/schema.go b/go-runtime/compile/schema.go index 1904b1a380..40ca38f2f6 100644 --- a/go-runtime/compile/schema.go +++ b/go-runtime/compile/schema.go @@ -10,6 +10,7 @@ import ( "reflect" "strings" "sync" + "unicode" "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/go/packages" @@ -417,6 +418,11 @@ func visitStruct(pctx *parseContext, node ast.Node, tnode types.Type) (*schema.D return nil, fmt.Errorf("field %s: %w", f.Name(), err) } + // Check if field is exported + if len(f.Name()) > 0 && unicode.IsLower(rune(f.Name()[0])) { + return nil, fmt.Errorf("params field %s must be exported by starting with an uppercase letter", f.Name()) + } + // Extract the JSON tag and split it to get just the field name tagContent := reflect.StructTag(s.Tag(i)).Get(aliasFieldTag) tagParts := strings.Split(tagContent, ",")