diff --git a/codegen/codegen.go b/codegen/codegen.go index 25989b8d3f7..df5d6e21a9e 100644 --- a/codegen/codegen.go +++ b/codegen/codegen.go @@ -50,6 +50,18 @@ func (tm TypeMap) Get(typeName string) *TypeMapEntry { return nil } +func (tm TypeMap) Check() error { + for idx, entry := range tm { + if entry.TypeName == "" { + return fmt.Errorf("entity #%d: typeName is not defined", idx+1) + } + if entry.EntityPath == "" { + return fmt.Errorf("entity #%d: entityPath is not defined", idx+1) + } + } + return nil +} + type TypeMapEntry struct { TypeName string `yaml:"typeName"` EntityPath string `yaml:"entityPath"` diff --git a/main.go b/main.go index 44cd3a08887..f4d49055ee7 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,11 @@ func main() { } types := loadTypeMap() + err = types.Check() + if err != nil { + fmt.Fprintln(os.Stderr, "invalid typemap format: "+err.Error()) + os.Exit(1) + } err = codegen.Generate(codegen.Config{ ModelFilename: *models,