From e87b64b51816bdb6700fb594ee4633409125c136 Mon Sep 17 00:00:00 2001 From: spinillos Date: Wed, 21 Jan 2026 17:31:19 +0100 Subject: [PATCH 1/7] Add internal map to deal with all extra fields --- internal/jennies/golang/types.go | 8 ++++++-- internal/simplecue/generator.go | 1 + internal/simplecue/utils.go | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/jennies/golang/types.go b/internal/jennies/golang/types.go index 7a0e06abd..7ea94ebe3 100644 --- a/internal/jennies/golang/types.go +++ b/internal/jennies/golang/types.go @@ -147,7 +147,7 @@ func (formatter *typeFormatter) doFormatType(def ast.Type, resolveBuilders bool) // anonymous struct or struct body if def.IsStruct() { - output := formatter.formatStructBody(def.AsStruct()) + output := formatter.formatStructBody(def.AsStruct(), def.HasHint(ast.HintOpenStruct)) if def.Nullable { output = "*" + output } @@ -177,7 +177,7 @@ func (formatter *typeFormatter) variantInterface(variant string) string { return referredPkg + "." + formatObjectName(variant) } -func (formatter *typeFormatter) formatStructBody(def ast.StructType) string { +func (formatter *typeFormatter) formatStructBody(def ast.StructType, isOpen bool) string { var buffer strings.Builder buffer.WriteString("struct {\n") @@ -189,6 +189,10 @@ func (formatter *typeFormatter) formatStructBody(def ast.StructType) string { } } + if isOpen { + buffer.WriteString("\n\n" + tools.Indent("ExtraFields map[string]any `json:\"-\"`", 4)) + } + buffer.WriteString("\n}") return buffer.String() diff --git a/internal/simplecue/generator.go b/internal/simplecue/generator.go index b16718b15..8f3ee5fb6 100644 --- a/internal/simplecue/generator.go +++ b/internal/simplecue/generator.go @@ -14,6 +14,7 @@ const cogAnnotationName = "cog" const cuetsyAnnotationName = "cuetsy" const hintKindEnum = "enum" const annotationKindFieldName = "kind" +const annotationOpen = "open" const enumMembersAttr = "memberNames" type LibraryInclude struct { diff --git a/internal/simplecue/utils.go b/internal/simplecue/utils.go index d6860cc9a..085ef97f1 100644 --- a/internal/simplecue/utils.go +++ b/internal/simplecue/utils.go @@ -101,7 +101,6 @@ func hintsFromCueValue(v cue.Value) ast.JenniesHints { for i < a.NumArgs() { key, value := a.Arg(i) hints[key] = value - i++ } } @@ -131,7 +130,12 @@ func getTypeHint(v cue.Value) (string, error) { return "", err } - if !found { + _, isOpen, err := attr.Lookup(0, annotationOpen) + if err != nil { + return "", err + } + + if !found && !isOpen { return "", errorWithCueRef(v, "no value for the %q key in @%s attribute", annotationKindFieldName, cogAnnotationName) } From a837317bcaa9c1c600ed9a599f0bef0f30e42d0e Mon Sep 17 00:00:00 2001 From: spinillos Date: Wed, 21 Jan 2026 17:31:27 +0100 Subject: [PATCH 2/7] Add tests --- .../GoRawTypes/open_struct/types_gen.go | 87 +++++++++++++++++++ testdata/jennies/rawtypes/open_struct/ir.json | 50 +++++++++++ .../jennies/rawtypes/open_struct/schema.cue | 6 ++ 3 files changed, 143 insertions(+) create mode 100644 testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go create mode 100644 testdata/jennies/rawtypes/open_struct/ir.json create mode 100644 testdata/jennies/rawtypes/open_struct/schema.cue diff --git a/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go new file mode 100644 index 000000000..d08a41ffc --- /dev/null +++ b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go @@ -0,0 +1,87 @@ +package open_struct + +import ( + "encoding/json" + cog "github.com/grafana/cog/generated/cog" + "errors" + "fmt" +) + +type OpenStruct struct { + A string `json:"a"` + B int64 `json:"b"` + + ExtraFields map[string]any `json:"-"` +} + +// NewOpenStruct creates a new OpenStruct object. +func NewOpenStruct() *OpenStruct { + return &OpenStruct{ +} +} +// UnmarshalJSONStrict implements a custom JSON unmarshalling logic to decode `OpenStruct` from JSON. +// Note: the unmarshalling done by this function is strict. It will fail over required fields being absent from the input, fields having an incorrect type, unexpected fields being present, … +func (resource *OpenStruct) UnmarshalJSONStrict(raw []byte) error { + if raw == nil { + return nil + } + var errs cog.BuildErrors + + fields := make(map[string]json.RawMessage) + if err := json.Unmarshal(raw, &fields); err != nil { + return err + } + // Field "a" + if fields["a"] != nil { + if string(fields["a"]) != "null" { + if err := json.Unmarshal(fields["a"], &resource.A); err != nil { + errs = append(errs, cog.MakeBuildErrors("a", err)...) + } + } else {errs = append(errs, cog.MakeBuildErrors("a", errors.New("required field is null"))...) + + } + delete(fields, "a") + } else {errs = append(errs, cog.MakeBuildErrors("a", errors.New("required field is missing from input"))...) + } + // Field "b" + if fields["b"] != nil { + if string(fields["b"]) != "null" { + if err := json.Unmarshal(fields["b"], &resource.B); err != nil { + errs = append(errs, cog.MakeBuildErrors("b", err)...) + } + } else {errs = append(errs, cog.MakeBuildErrors("b", errors.New("required field is null"))...) + + } + delete(fields, "b") + } else {errs = append(errs, cog.MakeBuildErrors("b", errors.New("required field is missing from input"))...) + } + + for field := range fields { + errs = append(errs, cog.MakeBuildErrors("OpenStruct", fmt.Errorf("unexpected field '%s'", field))...) + } + + if len(errs) == 0 { + return nil + } + + return errs +} + + +// Equals tests the equality of two `OpenStruct` objects. +func (resource OpenStruct) Equals(other OpenStruct) bool { + if resource.A != other.A { + return false + } + if resource.B != other.B { + return false + } + + return true +} + + +// Validate checks all the validation constraints that may be defined on `OpenStruct` fields for violations and returns them. +func (resource OpenStruct) Validate() error { + return nil +} diff --git a/testdata/jennies/rawtypes/open_struct/ir.json b/testdata/jennies/rawtypes/open_struct/ir.json new file mode 100644 index 000000000..36857bed1 --- /dev/null +++ b/testdata/jennies/rawtypes/open_struct/ir.json @@ -0,0 +1,50 @@ +{ + "Package": "open_struct", + "Metadata": {}, + "EntryPointType": { + "Kind": "", + "Nullable": false + }, + "Objects": { + "OpenStruct": { + "Name": "OpenStruct", + "Type": { + "Kind": "struct", + "Nullable": false, + "Struct": { + "Fields": [ + { + "Name": "a", + "Type": { + "Kind": "scalar", + "Nullable": false, + "Scalar": { + "ScalarKind": "string" + } + }, + "Required": true + }, + { + "Name": "b", + "Type": { + "Kind": "scalar", + "Nullable": false, + "Scalar": { + "ScalarKind": "int64" + } + }, + "Required": true + } + ] + }, + "Hints": { + "open": "true" + } + }, + "SelfRef": { + "ReferredPkg": "open_struct", + "ReferredType": "OpenStruct" + } + } + } +} diff --git a/testdata/jennies/rawtypes/open_struct/schema.cue b/testdata/jennies/rawtypes/open_struct/schema.cue new file mode 100644 index 000000000..849d0ef1c --- /dev/null +++ b/testdata/jennies/rawtypes/open_struct/schema.cue @@ -0,0 +1,6 @@ +package open_struct + +OpenStruct: { + a: string + b: int +} @cog(open=true) From db56180e09d0b3d351b3b8cc10e2559206b373b8 Mon Sep 17 00:00:00 2001 From: spinillos Date: Thu, 22 Jan 2026 12:23:51 +0100 Subject: [PATCH 3/7] Add Marshal and Unmarshal functions --- internal/jennies/golang/jsonmarshalling.go | 46 +++++++++++++++ .../types/open_struct.json_marshal.tmpl | 20 +++++++ .../types/open_struct.json_unmarshal.tmpl | 34 +++++++++++ .../GoRawTypes/open_struct/types_gen.go | 59 ++++++++++++++++++- 4 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl create mode 100644 internal/jennies/golang/templates/types/open_struct.json_unmarshal.tmpl diff --git a/internal/jennies/golang/jsonmarshalling.go b/internal/jennies/golang/jsonmarshalling.go index b9ffd68d9..730139d12 100644 --- a/internal/jennies/golang/jsonmarshalling.go +++ b/internal/jennies/golang/jsonmarshalling.go @@ -58,6 +58,22 @@ func (jenny JSONMarshalling) generateForObject(buffer *strings.Builder, context buffer.WriteString("\n") } + if jenny.objectIsOpenStruct(object) { + jsonMarshal, err := jenny.renderOpenStructMarshal(object) + if err != nil { + return err + } + buffer.WriteString(jsonMarshal) + buffer.WriteString("\n") + + jsonUnmarshal, err := jenny.renderOpenStructUnmarshal(object) + if err != nil { + return err + } + buffer.WriteString(jsonUnmarshal) + buffer.WriteString("\n") + } + return nil } @@ -229,3 +245,33 @@ func (resource *%[1]s) UnmarshalJSON(raw []byte) error { } `, formatObjectName(obj.Name), buffer.String()), nil } + +func (jenny JSONMarshalling) objectIsOpenStruct(obj ast.Object) bool { + return obj.Type.HasHint(ast.HintOpenStruct) +} + +func (jenny JSONMarshalling) renderOpenStructMarshal(obj ast.Object) (string, error) { + jenny.apiRefCollector.ObjectMethod(obj, common.MethodReference{ + Name: "MarshalJSON", + Comments: []string{ + fmt.Sprintf("MarshalJSON implements a custom JSON marshalling logic to encode `%s` as JSON.", formatObjectName(obj.Name)), + }, + Return: "([]byte, error)", + }) + return jenny.tmpl.Render("types/open_struct.json_marshal.tmpl", map[string]any{ + "def": obj, + }) +} + +func (jenny JSONMarshalling) renderOpenStructUnmarshal(obj ast.Object) (string, error) { + jenny.apiRefCollector.ObjectMethod(obj, common.MethodReference{ + Name: "MarshalJSON", + Comments: []string{ + fmt.Sprintf("MarshalJSON implements a custom JSON marshalling logic to encode `%s` as JSON.", formatObjectName(obj.Name)), + }, + Return: "([]byte, error)", + }) + return jenny.tmpl.Render("types/open_struct.json_unmarshal.tmpl", map[string]any{ + "def": obj, + }) +} diff --git a/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl b/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl new file mode 100644 index 000000000..7cf6114df --- /dev/null +++ b/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl @@ -0,0 +1,20 @@ +{{- $json := importStdPkg "encoding/json" -}} +// MarshalJSON implements a custom JSON marshalling logic to encode `{{ .def.Name|formatObjectName }}` as JSON. +func (resource *{{ .def.Name|formatObjectName }}) MarshalJSON() ([]byte, error) { + type Alias *{{ .def.Name }} + base, err := json.Marshal(Alias(resource)) + if err != nil { + return nil, err + } + + var baseMap map[string]any + if err := json.Unmarshal(base, &baseMap); err != nil { + return nil, err + } + + for k, v := range resource.ExtraFields { + baseMap[k] = v + } + + return json.Marshal(baseMap) +} diff --git a/internal/jennies/golang/templates/types/open_struct.json_unmarshal.tmpl b/internal/jennies/golang/templates/types/open_struct.json_unmarshal.tmpl new file mode 100644 index 000000000..397fe8181 --- /dev/null +++ b/internal/jennies/golang/templates/types/open_struct.json_unmarshal.tmpl @@ -0,0 +1,34 @@ +{{- $json := importStdPkg "encoding/json" -}} +{{- $errors := importStdPkg "errors" -}} +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `{{ .def.Name|formatObjectName }}` from JSON. +func (resource *{{ .def.Name|formatObjectName }}) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + var data map[string]json.RawMessage + if err := json.Unmarshal(raw, &data); err != nil { + return err + } + + {{- range .def.Type.Struct.Fields }} + // {{ .Name | upperCamelCase }} + if v, ok := data["{{ .Name }}"]; ok { + if err := json.Unmarshal(v, &resource.{{ .Name | upperCamelCase }}); err != nil { + return err + } + delete(data, "{{ .Name }}") + } + {{- end }} + + resource.ExtraFields = make(map[string]any) + for key, value := range data { + var v any + if err := json.Unmarshal(value, &v); err != nil { + return err + } + resource.ExtraFields[key] = v + } + + return nil +} diff --git a/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go index d08a41ffc..5ddbb21d9 100644 --- a/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go +++ b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go @@ -2,8 +2,8 @@ package open_struct import ( "encoding/json" - cog "github.com/grafana/cog/generated/cog" "errors" + cog "github.com/grafana/cog/generated/cog" "fmt" ) @@ -19,6 +19,63 @@ func NewOpenStruct() *OpenStruct { return &OpenStruct{ } } +// MarshalJSON implements a custom JSON marshalling logic to encode `OpenStruct` as JSON. +func (resource *OpenStruct) MarshalJSON() ([]byte, error) { + type Alias *OpenStruct + base, err := json.Marshal(Alias(resource)) + if err != nil { + return nil, err + } + + var baseMap map[string]any + if err := json.Unmarshal(base, &baseMap); err != nil { + return nil, err + } + + for k, v := range resource.ExtraFields { + baseMap[k] = v + } + + return json.Marshal(baseMap) +} + +// UnmarshalJSON implements a custom JSON unmarshalling logic to decode `OpenStruct` from JSON. +func (resource *OpenStruct) UnmarshalJSON(raw []byte) error { + if raw == nil { + return nil + } + + var data map[string]json.RawMessage + if err := json.Unmarshal(raw, &data); err != nil { + return err + } + // A + if v, ok := data["a"]; ok { + if err := json.Unmarshal(v, &resource.A); err != nil { + return err + } + delete(data, "a") + } + // B + if v, ok := data["b"]; ok { + if err := json.Unmarshal(v, &resource.B); err != nil { + return err + } + delete(data, "b") + } + + resource.ExtraFields = make(map[string]any) + for key, value := range data { + var v any + if err := json.Unmarshal(value, &v); err != nil { + return err + } + resource.ExtraFields[key] = v + } + + return nil +} + // UnmarshalJSONStrict implements a custom JSON unmarshalling logic to decode `OpenStruct` from JSON. // Note: the unmarshalling done by this function is strict. It will fail over required fields being absent from the input, fields having an incorrect type, unexpected fields being present, … func (resource *OpenStruct) UnmarshalJSONStrict(raw []byte) error { From 5792c2c98bbab29a553273d7c461d918f2e61c1b Mon Sep 17 00:00:00 2001 From: spinillos Date: Thu, 22 Jan 2026 12:56:10 +0100 Subject: [PATCH 4/7] fix marshal function --- .../golang/templates/types/open_struct.json_marshal.tmpl | 4 ++-- .../rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl b/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl index 7cf6114df..5fefee1e8 100644 --- a/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl +++ b/internal/jennies/golang/templates/types/open_struct.json_marshal.tmpl @@ -1,8 +1,8 @@ {{- $json := importStdPkg "encoding/json" -}} // MarshalJSON implements a custom JSON marshalling logic to encode `{{ .def.Name|formatObjectName }}` as JSON. func (resource *{{ .def.Name|formatObjectName }}) MarshalJSON() ([]byte, error) { - type Alias *{{ .def.Name }} - base, err := json.Marshal(Alias(resource)) + type {{ .def.Name | lowerCamelCase }} {{ .def.Name }} + base, err := json.Marshal((*{{ .def.Name | lowerCamelCase }})(resource)) if err != nil { return nil, err } diff --git a/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go index 5ddbb21d9..5f7b7cdc4 100644 --- a/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go +++ b/testdata/jennies/rawtypes/open_struct/GoRawTypes/open_struct/types_gen.go @@ -21,8 +21,8 @@ func NewOpenStruct() *OpenStruct { } // MarshalJSON implements a custom JSON marshalling logic to encode `OpenStruct` as JSON. func (resource *OpenStruct) MarshalJSON() ([]byte, error) { - type Alias *OpenStruct - base, err := json.Marshal(Alias(resource)) + type openStruct OpenStruct + base, err := json.Marshal((*openStruct)(resource)) if err != nil { return nil, err } From a78ca802e4ec7543b8d0dd97231793422dc1fb03 Mon Sep 17 00:00:00 2001 From: spinillos Date: Thu, 22 Jan 2026 17:56:37 +0100 Subject: [PATCH 5/7] Skip test for other languages --- internal/jennies/java/rawtypes_test.go | 3 +++ internal/jennies/jsonschema/schema_test.go | 3 +++ internal/jennies/openapi/schema_test.go | 3 +++ internal/jennies/php/rawtypes_test.go | 1 + internal/jennies/python/rawtypes_test.go | 1 + internal/jennies/typescript/rawtypes_test.go | 3 +++ 6 files changed, 14 insertions(+) diff --git a/internal/jennies/java/rawtypes_test.go b/internal/jennies/java/rawtypes_test.go index 6b6f76830..b43d31eea 100644 --- a/internal/jennies/java/rawtypes_test.go +++ b/internal/jennies/java/rawtypes_test.go @@ -14,6 +14,9 @@ func TestRawTypes_Generate(t *testing.T) { test := testutils.GoldenFilesTestSuite[ast.Schema]{ TestDataRoot: "../../../testdata/jennies/rawtypes", Name: "JavaRawTypes", + Skip: map[string]string{ + "open_struct": "TODO", + }, } cfg := Config{ diff --git a/internal/jennies/jsonschema/schema_test.go b/internal/jennies/jsonschema/schema_test.go index fa8792262..19c597419 100644 --- a/internal/jennies/jsonschema/schema_test.go +++ b/internal/jennies/jsonschema/schema_test.go @@ -13,6 +13,9 @@ func TestSchema_Generate(t *testing.T) { test := testutils.GoldenFilesTestSuite[ast.Schema]{ TestDataRoot: "../../../testdata/jennies/rawtypes", Name: "JSONSchema", + Skip: map[string]string{ + "open_struct": "TODO", + }, } config := Config{Debug: true} diff --git a/internal/jennies/openapi/schema_test.go b/internal/jennies/openapi/schema_test.go index 8cb62c1fe..094a86cd5 100644 --- a/internal/jennies/openapi/schema_test.go +++ b/internal/jennies/openapi/schema_test.go @@ -13,6 +13,9 @@ func TestSchema_Generate(t *testing.T) { test := testutils.GoldenFilesTestSuite[ast.Schema]{ TestDataRoot: "../../../testdata/jennies/rawtypes", Name: "OpenAPI", + Skip: map[string]string{ + "open_struct": "TODO", + }, } config := Config{debug: true} diff --git a/internal/jennies/php/rawtypes_test.go b/internal/jennies/php/rawtypes_test.go index 2d949ef4a..d6a260b8c 100644 --- a/internal/jennies/php/rawtypes_test.go +++ b/internal/jennies/php/rawtypes_test.go @@ -16,6 +16,7 @@ func TestRawTypes_Generate(t *testing.T) { Name: "PHPRawTypes", Skip: map[string]string{ "intersections": "Intersections are not implemented", + "open_struct": "TODO", }, } diff --git a/internal/jennies/python/rawtypes_test.go b/internal/jennies/python/rawtypes_test.go index eb3f97495..b25a05ef7 100644 --- a/internal/jennies/python/rawtypes_test.go +++ b/internal/jennies/python/rawtypes_test.go @@ -17,6 +17,7 @@ func TestRawTypes_Generate(t *testing.T) { Skip: map[string]string{ "intersections": "Intersections are not implemented", "dashboard": "the dashboard test schema includes a composable slot, which rely on external input to be properly supported", + "open_struct": "TODO", }, } diff --git a/internal/jennies/typescript/rawtypes_test.go b/internal/jennies/typescript/rawtypes_test.go index 09543f7bd..b586e4eba 100644 --- a/internal/jennies/typescript/rawtypes_test.go +++ b/internal/jennies/typescript/rawtypes_test.go @@ -14,6 +14,9 @@ func TestRawTypes_Generate(t *testing.T) { test := testutils.GoldenFilesTestSuite[ast.Schema]{ TestDataRoot: "../../../testdata/jennies/rawtypes", Name: "TypescriptRawTypes", + Skip: map[string]string{ + "open_struct": "TODO", + }, } config := Config{} From 6ac155d2e3a71f7038f4afcd705c5de003c5db59 Mon Sep 17 00:00:00 2001 From: spinillos Date: Thu, 22 Jan 2026 18:04:36 +0100 Subject: [PATCH 6/7] Fix lint --- internal/jennies/jsonschema/schema_test.go | 16 ++++++++-------- internal/jennies/php/rawtypes_test.go | 2 +- internal/jennies/python/rawtypes_test.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/jennies/jsonschema/schema_test.go b/internal/jennies/jsonschema/schema_test.go index 19c597419..44e6fd12c 100644 --- a/internal/jennies/jsonschema/schema_test.go +++ b/internal/jennies/jsonschema/schema_test.go @@ -2,7 +2,7 @@ package jsonschema import ( "testing" - + "github.com/grafana/cog/internal/ast" "github.com/grafana/cog/internal/languages" "github.com/grafana/cog/internal/testutils" @@ -13,31 +13,31 @@ func TestSchema_Generate(t *testing.T) { test := testutils.GoldenFilesTestSuite[ast.Schema]{ TestDataRoot: "../../../testdata/jennies/rawtypes", Name: "JSONSchema", - Skip: map[string]string{ + Skip: map[string]string{ "open_struct": "TODO", }, } - + config := Config{Debug: true} jenny := Schema{Config: config} compilerPasses := New(config).CompilerPasses() - + test.Run(t, func(tc *testutils.Test[ast.Schema]) { req := require.New(tc) - + // We run the compiler passes defined fo JSONSchema since without them, we // might not be able to translate some of the IR's semantics. schema := tc.UnmarshalJSONInput(testutils.RawTypesIRInputFile) processedAsts, err := compilerPasses.Process(ast.Schemas{&schema}) req.NoError(err) - + req.Len(processedAsts, 1, "we somehow got more ast.Schema than we put in") - + files, err := jenny.Generate(languages.Context{ Schemas: processedAsts, }) req.NoError(err) - + tc.WriteFiles(files) }) } diff --git a/internal/jennies/php/rawtypes_test.go b/internal/jennies/php/rawtypes_test.go index d6a260b8c..ddd703ae6 100644 --- a/internal/jennies/php/rawtypes_test.go +++ b/internal/jennies/php/rawtypes_test.go @@ -16,7 +16,7 @@ func TestRawTypes_Generate(t *testing.T) { Name: "PHPRawTypes", Skip: map[string]string{ "intersections": "Intersections are not implemented", - "open_struct": "TODO", + "open_struct": "TODO", }, } diff --git a/internal/jennies/python/rawtypes_test.go b/internal/jennies/python/rawtypes_test.go index b25a05ef7..9d5f85e8a 100644 --- a/internal/jennies/python/rawtypes_test.go +++ b/internal/jennies/python/rawtypes_test.go @@ -17,7 +17,7 @@ func TestRawTypes_Generate(t *testing.T) { Skip: map[string]string{ "intersections": "Intersections are not implemented", "dashboard": "the dashboard test schema includes a composable slot, which rely on external input to be properly supported", - "open_struct": "TODO", + "open_struct": "TODO", }, } From b1e009540148a116da2d4b3fcb7f4a539f49c45b Mon Sep 17 00:00:00 2001 From: spinillos Date: Thu, 22 Jan 2026 18:12:46 +0100 Subject: [PATCH 7/7] fmt --- internal/jennies/jsonschema/schema_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/jennies/jsonschema/schema_test.go b/internal/jennies/jsonschema/schema_test.go index 44e6fd12c..daaf8e454 100644 --- a/internal/jennies/jsonschema/schema_test.go +++ b/internal/jennies/jsonschema/schema_test.go @@ -2,7 +2,7 @@ package jsonschema import ( "testing" - + "github.com/grafana/cog/internal/ast" "github.com/grafana/cog/internal/languages" "github.com/grafana/cog/internal/testutils" @@ -17,27 +17,27 @@ func TestSchema_Generate(t *testing.T) { "open_struct": "TODO", }, } - + config := Config{Debug: true} jenny := Schema{Config: config} compilerPasses := New(config).CompilerPasses() - + test.Run(t, func(tc *testutils.Test[ast.Schema]) { req := require.New(tc) - + // We run the compiler passes defined fo JSONSchema since without them, we // might not be able to translate some of the IR's semantics. schema := tc.UnmarshalJSONInput(testutils.RawTypesIRInputFile) processedAsts, err := compilerPasses.Process(ast.Schemas{&schema}) req.NoError(err) - + req.Len(processedAsts, 1, "we somehow got more ast.Schema than we put in") - + files, err := jenny.Generate(languages.Context{ Schemas: processedAsts, }) req.NoError(err) - + tc.WriteFiles(files) }) }