@@ -57,11 +57,16 @@ func (p *SchemaParser) ParseFile(path string) (*SchemaData, error) {
5757 return nil , fmt .Errorf ("failed to read file: %w" , err )
5858 }
5959
60- var schemaObj entities.Schema
60+ // Use a temporary struct for unmarshaling that matches the file structure
61+ var fileData struct {
62+ Description string `json:"description" yaml:"description"`
63+ Variables []entities.Variable `json:"variables" yaml:"variables"`
64+ Extends []string `json:"extends" yaml:"extends"`
65+ }
6166
6267 // Try YAML first, then JSON, then dotenv as fallback
63- if err := yaml .Unmarshal (data , & schemaObj ); err != nil {
64- if err := json .Unmarshal (data , & schemaObj ); err != nil {
68+ if err := yaml .Unmarshal (data , & fileData ); err != nil {
69+ if err := json .Unmarshal (data , & fileData ); err != nil {
6570 // Try parsing as dotenv file as fallback
6671 dotenvParser := NewAnnotatedDotEnvParser ()
6772 _ , schema , parseErr := dotenvParser .ParseFile (path )
@@ -77,17 +82,19 @@ func (p *SchemaParser) ParseFile(path string) (*SchemaData, error) {
7782 Extends : nil ,
7883 }, nil
7984 }
85+ // JSON parsing succeeded
8086 return & SchemaData {
81- Description : schemaObj .Description ,
82- Variables : schemaObj .Variables ,
83- Extends : schemaObj .Extends ,
87+ Description : fileData .Description ,
88+ Variables : fileData .Variables ,
89+ Extends : fileData .Extends ,
8490 }, nil
8591 }
8692
93+ // YAML parsing succeeded
8794 return & SchemaData {
88- Description : schemaObj .Description ,
89- Variables : schemaObj .Variables ,
90- Extends : schemaObj .Extends ,
95+ Description : fileData .Description ,
96+ Variables : fileData .Variables ,
97+ Extends : fileData .Extends ,
9198 }, nil
9299}
93100
0 commit comments