package docs import ( "os" "strings" "testing" ) func TestCreateGrowthReportRequestFieldsAreOptional(t *testing.T) { t.Parallel() document, err := os.ReadFile("openapi.yaml") if err != nil { t.Fatalf("read OpenAPI document: %v", err) } const schemaStart = " CreateGrowthReportRequest:\n" const nextSchema = " GrowthRange:\n" start := strings.Index(string(document), schemaStart) if start < 0 { t.Fatal("CreateGrowthReportRequest schema not found") } schema := string(document)[start+len(schemaStart):] var found bool schema, _, found = strings.Cut(schema, nextSchema) if !found { t.Fatal("schema following CreateGrowthReportRequest not found") } if strings.Contains(schema, "required:") { t.Fatalf("optional request fields must not be listed as required:\n%s", schema) } if strings.Contains(schema, "default:") { t.Fatalf("optional request fields must not use defaults that generators treat as required:\n%s", schema) } }