Пример #1
0
// 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,
		Principal:     s.Principal,
	}

	if !s.SkipModels && (len(s.Models) > 0 || len(s.Operations) == 0) {
		if err := generator.GenerateDefinition(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, opts); err != nil {
			return err
		}
	}

	return nil
}
Пример #2
0
// Execute generates the supporting files file
func (s *Support) Execute(args []string) error {
	return generator.GenerateSupport(
		s.Name,
		nil,
		nil,
		generator.GenOpts{
			Spec:          string(s.Spec),
			Target:        string(s.Target),
			APIPackage:    s.APIPackage,
			ModelPackage:  s.ModelPackage,
			ServerPackage: s.ServerPackage,
			ClientPackage: s.ClientPackage,
			Principal:     s.Principal,
			DumpData:      s.DumpData,
		})
}