gen/writers/generate.go
func GenerateMetadata(descriptor *gen.APIDescriptor, codegen, pkg string) error {
	f, err := os.Create(codegen)
	if err != nil {
		return err
	}
	c, err := NewMetadataWriter()
	if err != nil {
		return err
	}
	kingpin.FatalIfError(c.WriteHeader(pkg, f), "")
	kingpin.FatalIfError(c.WriteMetadata(descriptor, f), "")
	f.Close()
	o, err := exec.Command("go", "fmt", codegen).CombinedOutput()
	if err != nil {
		return fmt.Errorf("Failed to format generated metadata code:\n%s", o)
	}
	return nil
}
func GenerateMetadata(descriptor *gen.APIDescriptor, codegen, pkg string) error {
	f, err := os.Create(codegen)
	if err != nil {
		return err
	}
	c, err := NewMetadataWriter()
	if err != nil {
		return err
	}
	kingpin.FatalIfError(c.WriteHeader(pkg, f), "")
	kingpin.FatalIfError(c.WriteMetadata(descriptor, f), "")
	f.Close()
	o, err := exec.Command("go", "fmt", codegen).CombinedOutput()
	if err != nil {
		return fmt.Errorf("Failed to format generated metadata code:\n%s", o)
	}
	return nil
}
// Generate API metadata, drives the metadata writer.