From 9704702a5c79a7c707edb69f0b2cd6ef95caeec9 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Thu, 11 Jun 2026 11:23:17 -0700 Subject: [PATCH 1/3] Converted openapi_generate to create samples instead of examples --- mmv1/openapi_generate/parser.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mmv1/openapi_generate/parser.go b/mmv1/openapi_generate/parser.go index 6a337894c138..c58c11eb3c25 100644 --- a/mmv1/openapi_generate/parser.go +++ b/mmv1/openapi_generate/parser.go @@ -394,12 +394,17 @@ func attachStandardFunctionality(resource api.Resource) api.Resource { resource.IdFormat = resource.SelfLink resource.ImportFormat = []string{resource.SelfLink} - example := r.Examples{} - example.Name = "name_of_example_file" - example.PrimaryResourceId = "example" - example.Vars = map[string]string{"resource_name": "test-resource"} + sample := r.Sample{} + sample.Name = "name_of_sample_file" + sample.PrimaryResourceId = "example" - resource.Examples = []*r.Examples{&example} + step := r.Step{} + step.Name = "name_of_sample_file" + step.Vars = map[string]string{"resource_name": "test-resource"} + + sample.Steps = []*r.Step{&step} + + resource.Samples = []*r.Sample{&sample} resourceNameBytes := []byte(resource.Name) // Write the status as an encoded string to flag when a YAML file has been From a331c9c726eba70a508dd76ebf6f03b53a386754 Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Thu, 11 Jun 2026 11:26:56 -0700 Subject: [PATCH 2/3] Added test for sample addition --- mmv1/openapi_generate/parser_test.go | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/mmv1/openapi_generate/parser_test.go b/mmv1/openapi_generate/parser_test.go index 5660430fb66d..932ab02c15b9 100644 --- a/mmv1/openapi_generate/parser_test.go +++ b/mmv1/openapi_generate/parser_test.go @@ -169,3 +169,43 @@ func TestReadOnlyPropagation(t *testing.T) { } } } + +func TestAttachStandardFunctionality(t *testing.T) { + resource := api.Resource{ + Name: "TestResource", + SelfLink: "test/self/link", + } + + result := attachStandardFunctionality(resource) + + if len(result.Examples) != 0 { + t.Errorf("Expected result.Examples to be empty, got: %d examples", len(result.Examples)) + } + + if len(result.Samples) != 1 { + t.Fatalf("Expected result.Samples to have length 1, got: %d", len(result.Samples)) + } + + sample := result.Samples[0] + if sample.Name != "name_of_sample_file" { + t.Errorf("Expected sample.Name to be 'name_of_sample_file', got: %q", sample.Name) + } + + if sample.PrimaryResourceId != "example" { + t.Errorf("Expected sample.PrimaryResourceId to be 'example', got: %q", sample.PrimaryResourceId) + } + + if len(sample.Steps) != 1 { + t.Fatalf("Expected sample.Steps to have length 1, got: %d", len(sample.Steps)) + } + + step := sample.Steps[0] + if step.Name != "name_of_sample_file" { + t.Errorf("Expected step.Name to be 'name_of_sample_file', got: %q", step.Name) + } + + if val, ok := step.Vars["resource_name"]; !ok || val != "test-resource" { + t.Errorf("Expected step.Vars['resource_name'] to be 'test-resource', got: %q (present=%t)", val, ok) + } +} + From 2580066c7382756ff7c77a6e5649deae2857073e Mon Sep 17 00:00:00 2001 From: Stephen Lewis Date: Thu, 11 Jun 2026 11:27:13 -0700 Subject: [PATCH 3/3] gofmt --- mmv1/openapi_generate/parser_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/openapi_generate/parser_test.go b/mmv1/openapi_generate/parser_test.go index 932ab02c15b9..a42f43a88533 100644 --- a/mmv1/openapi_generate/parser_test.go +++ b/mmv1/openapi_generate/parser_test.go @@ -208,4 +208,3 @@ func TestAttachStandardFunctionality(t *testing.T) { t.Errorf("Expected step.Vars['resource_name'] to be 'test-resource', got: %q (present=%t)", val, ok) } } -