// Execute runs this command func (s *Server) Execute(args []string) error { opts := generator.GenOpts{ Spec: string(s.Spec), Target: string(s.Target), APIPackage: s.APIPackage, ModelPackage: s.ModelPackage, ServerPackage: s.ServerPackage, ClientPackage: s.ClientPackage, TestPackage: s.TestPackage, Principal: s.Principal, } if !s.SkipModels && (len(s.Models) > 0 || len(s.Operations) == 0) { if err := generator.GenerateModel(s.Models, true, true, opts); err != nil { return err } } if !s.SkipOperations && (len(s.Operations) > 0 || len(s.Models) == 0) { if err := generator.GenerateServerOperation(s.Operations, s.Tags, true, true, opts); err != nil { return err } } if !s.SkipSupport { if err := generator.GenerateSupport(s.Name, s.Models, s.Operations, s.IncludeUI, opts); err != nil { return err } } return nil }
// Execute generates a model file func (m *Model) Execute(args []string) error { if m.DumpData && len(m.Name) > 1 { return errors.New("only 1 model at a time is supported for dumping data") } return generator.GenerateModel( m.Name, !m.NoStruct, !m.NoValidator, generator.GenOpts{ Spec: string(m.Spec), Target: string(m.Target), APIPackage: m.APIPackage, ModelPackage: m.ModelPackage, ServerPackage: m.ServerPackage, ClientPackage: m.ClientPackage, DumpData: m.DumpData, }) }