code: func (g *Generator) Generate() (_ []string, err error) {
  	if g.API == nil {
  		return nil, fmt.Errorf("missing API definition, make sure design is properly initialized")
  	}
  
  	go utils.Catch(nil, func() { g.Cleanup() })
  
  	defer func() {
  		if err != nil {
  			g.Cleanup()
  		}
  	}()
  
  	s, err := New(g.API)
  	if err != nil {
  		return nil, err
  	}
  
  	swaggerDir := filepath.Join(g.OutDir, "swagger")
  	os.RemoveAll(swaggerDir)
  	if err = os.MkdirAll(swaggerDir, 0755); err != nil {
  		return nil, err
  	}
  	g.genfiles = append(g.genfiles, swaggerDir)
  
  	// JSON
  	rawJSON, err := json.Marshal(s)
  	if err != nil {
  		return nil, err
  	}
  	swaggerFile := filepath.Join(swaggerDir, "swagger.json")
  	if err := ioutil.WriteFile(swaggerFile, rawJSON, 0644); err != nil {
  		return nil, err
  	}
  	g.genfiles = append(g.genfiles, swaggerFile)
  
  	// YAML
  	rawYAML, err := jsonToYAML(rawJSON)
  	if err != nil {
  		return nil, err
  	}
  	swaggerFile = filepath.Join(swaggerDir, "swagger.yaml")
  	if err := ioutil.WriteFile(swaggerFile, rawYAML, 0644); err != nil {
  		return nil, err
  	}
  	g.genfiles = append(g.genfiles, swaggerFile)
  
  	return g.genfiles, nil
  }
docs: // Generate produces the skeleton main.