// generate code of this library
339595
func (l *library) generate() error {
	// write empty __init__.py in each dir
	walkFn := func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if !info.IsDir() {
			return nil
		}
		return generateEmptyInitPy(path)
	}

	if err := filepath.Walk(l.baseDir, walkFn); err != nil {
		return err
	}

	// json schema
	if err := generateJSONSchema(&raml.APIDefinition{
		Types: l.Types,
	}, l.dir); err != nil {
		log.Errorf("failed to generate jsonschema:%v", err)
		return err
	}

	// security schemes
	if err := generateServerSecurity(l.SecuritySchemes, templates(serverKindFlask), l.dir); err != nil {
		return err
	}

	// included libraries
	for _, ramlLib := range l.Libraries {
		childLib := newLibrary(ramlLib, l.baseDir)
		if err := childLib.generate(); err != nil {
			return err
		}
	}
	return nil
}
837453
func (g *Generator) generate(file *FileDescriptor) {
	g.file = file
	g.usedPackages = make(map[GoImportPath]bool)
	g.packageNames = make(map[GoImportPath]GoPackageName)
	g.usedPackageNames = make(map[GoPackageName]bool)
	g.addedImports = make(map[GoImportPath]bool)
	for name := range globalPackageNames {
		g.usedPackageNames[name] = true
	}

	g.P("// This is a compile-time assertion to ensure that this generated file")
	g.P("// is compatible with the proto package it is being compiled against.")
	g.P("// A compilation error at this line likely means your copy of the")
	g.P("// proto package needs to be updated.")
	g.P("const _ = ", g.Pkg["proto"], ".ProtoPackageIsVersion", generatedCodeVersion, " // please upgrade the proto package")
	g.P()

	for _, td := range g.file.imp {
		g.generateImported(td)
	}
	for _, enum := range g.file.enum {
		g.generateEnum(enum)
	}
	for _, desc := range g.file.desc {
		// Don't generate virtual messages for maps.
		if desc.GetOptions().GetMapEntry() {
			continue
		}
		g.generateMessage(desc)
	}
	for _, ext := range g.file.ext {
		g.generateExtension(ext)
	}
	g.generateInitFunction()
	g.generateFileDescriptor(file)

	// Run the plugins before the imports so we know which imports are necessary.
	g.runPlugins(file)

	// Generate header and imports last, though they appear first in the output.
	rem := g.Buffer
	remAnno := g.annotations
	g.Buffer = new(bytes.Buffer)
	g.annotations = nil
	g.generateHeader()
	g.generateImports()
	if !g.writeOutput {
		return
	}
	// Adjust the offsets for annotations displaced by the header and imports.
	for _, anno := range remAnno {
		*anno.Begin += int32(g.Len())
		*anno.End += int32(g.Len())
		g.annotations = append(g.annotations, anno)
	}
	g.Write(rem.Bytes())

	// Reformat generated code and patch annotation locations.
	fset := token.NewFileSet()
	original := g.Bytes()
	if g.annotateCode {
		// make a copy independent of g; we'll need it after Reset.
		original = append([]byte(nil), original...)
	}
	fileAST, err := parser.ParseFile(fset, "", original, parser.ParseComments)
	if err != nil {
		// Print out the bad code with line numbers.
		// This should never happen in practice, but it can while changing generated code,
		// so consider this a debugging aid.
		var src bytes.Buffer
		s := bufio.NewScanner(bytes.NewReader(original))
		for line := 1; s.Scan(); line++ {
			fmt.Fprintf(&src, "%5d\t%s\n", line, s.Bytes())
		}
		g.Fail("bad Go source code was generated:", err.Error(), "\n"+src.String())
	}
	ast.SortImports(fset, fileAST)
	g.Reset()
	err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(g, fset, fileAST)
	if err != nil {
		g.Fail("generated Go source code could not be reformatted:", err.Error())
	}
	if g.annotateCode {
		m, err := remap.Compute(original, g.Bytes())
		if err != nil {
			g.Fail("formatted generated Go source code could not be mapped back to the original code:", err.Error())
		}
		for _, anno := range g.annotations {
			new, ok := m.Find(int(*anno.Begin), int(*anno.End))
			if !ok {
				g.Fail("span in formatted generated Go source code could not be mapped back to the original code")
			}
			*anno.Begin = int32(new.Pos)
			*anno.End = int32(new.End)
		}
	}
}
1268946
func generateStubs(debugMode bool, state *PkgState) {
	t, err := bindgen.Parse(model, hdrfile)
	handleErr(err)
	var buf io.WriteCloser
	var fullpath string
	if debugMode {
		filename := "generated_FOO.go"
		fullpath = path.Join(pkgloc, filename)
		buf, err = os.OpenFile(fullpath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
		handleErr(err)
		fmt.Fprintln(buf, pkghdr)
	}

	decls := state.TypeDecls()

	var todoCount int
outer:
	for k, vs := range setFns {
		if isIgnored(k) {
			continue
		}
		var hasTODO bool
		gotype, ok := ctypes2GoTypes[k]
		if !ok {
			log.Printf("Cannot generate for %q", k)
			continue
		}
		if alreadyProcessedType(gotype, decls) {
			continue
		}

		// if we're not in debugging mode, then we should write out to different files per type generated
		// this makes it easier to work on all the TODOs
		if !debugMode {
			filename := fmt.Sprintf("generated_%v.go", strings.ToLower(gotype))
			fullpath = path.Join(pkgloc, filename)
			buf, err = os.OpenFile(fullpath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
			handleErr(err)
			fmt.Fprintln(buf, pkghdr)
		}

		for _, v := range vs {
			if isIgnored(v) {
				log.Printf("Skipped generating for %q", k)
				continue outer
			}
		}

		// get the creation function to "guess" what should be in the struct
		filter := func(decl *cc.Declarator) bool {
			if decl.Type.Kind() != cc.Function {
				return false
			}
			n := bindgen.NameOf(decl)
			for _, v := range vs {
				if n == v {
					return true
				}
			}
			return false
		}
		decls, err := bindgen.Get(t, filter)
		handleErr(err)

		cs := decls[0].(*bindgen.CSignature)
		sig := GoSignature{}
		var create, destroy string
		if creates, ok := creations[k]; ok {
			create = creates[0]
		}
		if destroys, ok := destructions[k]; ok {
			destroy = destroys[0]
		}

		if create == "" || destroy == "" {
			log.Printf("Skipped %v - No Create/Destroy", k)
			continue
		}

		body := Con{
			Ctype:   k,
			GoType:  gotype,
			Create:  create,
			Destroy: destroy,
			Set:     vs,
		}
		sig.Receiver = Param{Name: "DUMMY", Type: "*" + gotype}
		sig.RetVals = append(sig.RetVals, Param{Name: "DUMMY"})

		if _, err = csig2gosig(cs, &sig); err != nil {
			body.TODO = err.Error()
			log.Print(body.TODO)
			hasTODO = true
		}
		sig.RetVals[0] = sig.Receiver
		sig.RetVals[0].Name = "retVal"
		sig.Receiver = Param{} // Param is set to empty

		for _, p := range sig.Params {
			body.Params = append(body.Params, p.Name)
			body.ParamType = append(body.ParamType, p.Type)
		}
		sig.Doc = fmt.Sprintf("New%v creates a new %v.", gotype, gotype)
		sig.Name = fmt.Sprintf("New%v", gotype)
		constructStructTemplate.Execute(buf, body)

		fmt.Fprintf(buf, "\n%v{ \n", sig)
		if len(vs) > 1 {
			hasTODO = true
			constructionTODOTemplate.Execute(buf, body)
		} else {
			constructionTemplate.Execute(buf, body)
		}
		fmt.Fprintf(buf, "}\n")

		// getters
		retValPos := getRetVal(cs)
		if len(vs) > 1 {
			fmt.Fprintf(buf, "// TODO: Getters for %v\n", gotype)
			goto generateDestructor
		}
		for i, p := range cs.Parameters() {
			if _, ok := retValPos[i]; ok {
				continue
			}
			getterSig := GoSignature{}
			typName := goNameOf(p.Type())

			// receiver - we don;t log - adds to the noise
			if typName == gotype {
				continue
			}

			if typName == "" {
				hasTODO = true
				fmt.Fprintf(buf, "//TODO: %q: Parameter %d Skipped %q of %v - unmapped type\n", cs.Name, i, p.Name(), p.Type())
				continue
			}
			getterSig.Doc = fmt.Sprintf("%v returns the internal %v.", strings.Title(p.Name()), p.Name())
			getterSig.Receiver.Name = strings.ToLower(string(gotype[0]))
			getterSig.Receiver.Type = reqPtr(gotype)
			getterSig.Name = strings.Title(p.Name())
			getterSig.RetVals = []Param{{Type: typName}}
			fmt.Fprintf(buf, "\n%v{ return %v.%v }\n", getterSig, getterSig.Receiver.Name, p.Name())
		}

	generateDestructor:
		// destructor
		destructor := GoSignature{}
		destructor.Name = "destroy" + gotype
		destructor.Params = []Param{
			{Name: "obj", Type: gotype, IsPtr: true},
		}
		fmt.Fprintf(buf, "\n%v{", destructor)
		destructTemplate.Execute(buf, body)
		fmt.Fprintf(buf, "}\n")

		if !debugMode {
			buf.Close()
			log.Printf("Written to %v. TODO: %v", fullpath, hasTODO)
			if err := goimports(fullpath); err != nil {
				log.Printf("Failed to Goimports %q: %v", fullpath, err)
			}
		}
		if hasTODO {
			todoCount++
		}
	}
	log.Printf("%d/%d TODOs", todoCount, len(setFns))

	buf.Close()
	if err := goimports(fullpath); err != nil {
		log.Printf("Failed to Goimports %q: %v", fullpath, err)
	}
}
1313024
func (gl *goLibrary) generate() error {
	// generate all Type structs
	if err := generateStructs(gl.Types, gl.targetDir()); err != nil {
		return err
	}

	// security schemes
	if err := generateSecurity(gl.SecuritySchemes, gl.targetDir(), gl.PackageName); err != nil {
		return err
	}

	// included libraries
	for name, ramlLib := range gl.Libraries {
		childLib := newGoLibrary(name, ramlLib, gl.targetDir(), gl.rootTargetDir, globLibRootURLs)
		if err := childLib.generate(); err != nil {
			return err
		}
	}
	return nil
}
1239272
func (t *transformer) generateClient(protoPackage, serviceName string, iface *ast.InterfaceType) ([]ast.Decl, error) {
	// This function used to construct an AST. It was a lot of code.
	// Now it generates code via a template and parses back to AST.
	// Slower, but saner and easier to make changes.

	type Method struct {
		Name          string
		InputMessage  string
		OutputMessage string
	}
	methods := make([]Method, 0, len(iface.Methods.List))

	var buf bytes.Buffer
	toGoCode := func(n ast.Node) (string, error) {
		defer buf.Reset()
		err := format.Node(&buf, t.fset, n)
		if err != nil {
			return "", err
		}
		return buf.String(), nil
	}

	for _, m := range iface.Methods.List {
		signature, ok := m.Type.(*ast.FuncType)
		if !ok {
			return nil, fmt.Errorf("unexpected embedded interface in %sClient", serviceName)
		}

		inStructPtr := signature.Params.List[1].Type.(*ast.StarExpr)
		inStruct, err := toGoCode(inStructPtr.X)
		if err != nil {
			return nil, err
		}

		outStructPtr := signature.Results.List[0].Type.(*ast.StarExpr)
		outStruct, err := toGoCode(outStructPtr.X)
		if err != nil {
			return nil, err
		}

		methods = append(methods, Method{
			Name:          m.Names[0].Name,
			InputMessage:  inStruct,
			OutputMessage: outStruct,
		})
	}

	prpcSymbolPrefix := "prpc."
	if t.inPRPCPackage {
		prpcSymbolPrefix = ""
	}
	err := clientCodeTemplate.Execute(&buf, map[string]interface{}{
		"Service":          serviceName,
		"ProtoPkg":         protoPackage,
		"StructName":       firstLower(serviceName) + "PRPCClient",
		"Methods":          methods,
		"PRPCSymbolPrefix": prpcSymbolPrefix,
	})
	if err != nil {
		return nil, fmt.Errorf("client template execution: %s", err)
	}

	f, err := parser.ParseFile(t.fset, "", buf.String(), 0)
	if err != nil {
		return nil, fmt.Errorf("client template result parsing: %s. Code: %#v", err, buf.String())
	}
	return f.Decls, nil
}
1248839
func (g *grpc) Generate(file *generator.FileDescriptor) {
	if len(file.FileDescriptorProto.Service) == 0 {
		return
	}

	contextPkg = string(g.gen.AddImport(contextPkgPath))
	grpcPkg = string(g.gen.AddImport(grpcPkgPath))

	g.P("// Reference imports to suppress errors if they are not otherwise used.")
	g.P("var _ ", contextPkg, ".Context")
	g.P("var _ ", grpcPkg, ".ClientConn")
	g.P()

	// Assert version compatibility.
	g.P("// This is a compile-time assertion to ensure that this generated file")
	g.P("// is compatible with the grpc package it is being compiled against.")
	g.P("const _ = ", grpcPkg, ".SupportPackageIsVersion", generatedCodeVersion)
	g.P()

	for i, service := range file.FileDescriptorProto.Service {
		g.generateService(file, service, i)
	}
}
1083432
func (gc Client) Generate() error {
	if err := commons.CheckDuplicatedTitleTypes(gc.apiDef); err != nil {
		return err
	}
	// helper package
	gh := goramlHelper{
		packageName: "goraml",
		packageDir:  "goraml",
	}
	if err := gh.generate(gc.TargetDir); err != nil {
		return err
	}

	// generate struct
	if err := generateAllStructs(gc.apiDef, gc.TargetDir); err != nil {
		return err
	}

	// libraries
	if err := generateLibraries(gc.libraries, gc.TargetDir, gc.libsRootURLs); err != nil {
		return err
	}

	if err := gc.generateHelperFile(gc.TargetDir); err != nil {
		return err
	}

	if err := gc.generateSecurity(gc.TargetDir); err != nil {
		return err
	}

	if err := gc.generateServices(gc.TargetDir); err != nil {
		return err
	}
	return gc.generateClientFile(gc.TargetDir)
}
137979
func (s *Server) Generate() error {
	if err := s.generateSchemas(); err != nil {
		return err
	}

	if err := s.generateMain(); err != nil {
		return err
	}

	return s.generateResources()
}
1129808
func Generate(schema *rdl.Schema, params *GeneratorParams) error {
	name := strings.ToLower(string(schema.Name))
	outdir := params.Outdir
	if outdir == "" {
		outdir = "."
		name = name + "_model.go"
	} else if strings.HasSuffix(outdir, ".go") {
		name = filepath.Base(outdir)
		outdir = filepath.Dir(outdir)
	} else {
		name = name + "_model.go"
	}
	err := os.MkdirAll(outdir, 0755)
	if err != nil {
		return err
	}
	filepath := outdir + "/" + name
	out, file, _, err := genutil.OutputWriter(filepath, "", ".go")
	if err != nil {
		return err
	}
	if file != nil {
		defer func() {
			file.Close()
			err := goFmt(filepath)
			if err != nil {
				fmt.Println("Warning: could not format go code:", err)
			}
		}()
	}
	gen := &modelGenerator{
		registry:       rdl.NewTypeRegistry(schema),
		schema:         schema,
		writer:         out,
		librdl:         params.LibRdl,
		prefixEnums:    params.PrefixEnums,
		precise:        params.PreciseTypes,
		err:            nil,
		untaggedUnions: params.UntaggedUnions,
		ns:             params.Namespace,
		rdl:            schema.Name == "rdl",
	}
	gen.emitHeader(params.Banner)
	if gen.err == nil {
		for _, t := range schema.Types {
			gen.emitType(t)
		}
	}
	out.Flush()
	if gen.err == nil {
		if params.GenerateSchema {
			gen.err = GenerateGoSchema(params.Banner, schema, outdir, params.Namespace, params.LibRdl, params.PrefixEnums)
		}
	}
	return gen.err
}
321248
func generateLibraries(libraries map[string]*raml.Library, baseDir string) error {
	for _, ramlLib := range libraries {
		pl := newLibrary(ramlLib, baseDir)

		if err := pl.generate(); err != nil {
			return err
		}
	}
	return nil
}
1155095
func (g *Generator) Generate() error {
	g.populateImports()
	if g.iface == nil {
		return ErrNotSetup
	}

	g.printf(
		"// %s is an autogenerated mock type for the %s type\n", g.mockName(),
		g.iface.Name,
	)

	g.printf(
		"type %s struct {\n\tmock.Mock\n}\n\n", g.mockName(),
	)

	for i := 0; i < g.iface.Type.NumMethods(); i++ {
		fn := g.iface.Type.Method(i)

		ftype := fn.Type().(*types.Signature)
		fname := fn.Name()

		params := g.genList(ftype.Params(), ftype.Variadic())
		returns := g.genList(ftype.Results(), false)

		if len(params.Names) == 0 {
			g.printf("// %s provides a mock function with given fields:\n", fname)
		} else {
			g.printf(
				"// %s provides a mock function with given fields: %s\n", fname,
				strings.Join(params.Names, ", "),
			)
		}
		g.printf(
			"func (_m *%s) %s(%s) ", g.mockName(), fname,
			strings.Join(params.Params, ", "),
		)

		switch len(returns.Types) {
		case 0:
			g.printf("{\n")
		case 1:
			g.printf("%s {\n", returns.Types[0])
		default:
			g.printf("(%s) {\n", strings.Join(returns.Types, ", "))
		}

		var formattedParamNames string
		for i, name := range params.Names {
			if i > 0 {
				formattedParamNames += ", "
			}

			paramType := params.Types[i]
			// for variable args, move the ... to the end.
			if strings.Index(paramType, "...") == 0 {
				name += "..."
			}
			formattedParamNames += name
		}

		called := g.generateCalled(params, formattedParamNames) // _m.Called invocation string

		if len(returns.Types) > 0 {
			g.printf("\tret := %s\n\n", called)

			var (
				ret []string
			)

			for idx, typ := range returns.Types {
				g.printf("\tvar r%d %s\n", idx, typ)
				g.printf("\tif rf, ok := ret.Get(%d).(func(%s) %s); ok {\n",
					idx, strings.Join(params.Types, ", "), typ)
				g.printf("\t\tr%d = rf(%s)\n", idx, formattedParamNames)
				g.printf("\t} else {\n")
				if typ == "error" {
					g.printf("\t\tr%d = ret.Error(%d)\n", idx, idx)
				} else if returns.Nilable[idx] {
					g.printf("\t\tif ret.Get(%d) != nil {\n", idx)
					g.printf("\t\t\tr%d = ret.Get(%d).(%s)\n", idx, idx, typ)
					g.printf("\t\t}\n")
				} else {
					g.printf("\t\tr%d = ret.Get(%d).(%s)\n", idx, idx, typ)
				}
				g.printf("\t}\n\n")

				ret = append(ret, fmt.Sprintf("r%d", idx))
			}

			g.printf("\treturn %s\n", strings.Join(ret, ", "))
		} else {
			g.printf("\t%s\n", called)
		}

		g.printf("}\n")
	}

	return nil
}
513926
func generateHeader(ctx *context, w io.Writer) {
	fmt.Fprintln(w, "// Code generated by GoVPP binapi-generator. DO NOT EDIT.")
	fmt.Fprintf(w, "//  source: %s\n", ctx.inputFile)
	fmt.Fprintln(w)

	fmt.Fprintln(w, "/*")
	fmt.Fprintf(w, " Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx.moduleName)
	fmt.Fprintln(w)
	fmt.Fprintln(w, " It contains following objects:")
	var printObjNum = func(obj string, num int) {
		if num > 0 {
			if num > 1 {
				if strings.HasSuffix(obj, "s") {
					obj += "es"
				} else {
					obj += "s"
				}
			}
			fmt.Fprintf(w, "\t%3d %s\n", num, obj)
		}
	}

	printObjNum("service", len(ctx.packageData.Services))
	printObjNum("enum", len(ctx.packageData.Enums))
	printObjNum("alias", len(ctx.packageData.Aliases))
	printObjNum("type", len(ctx.packageData.Types))
	printObjNum("union", len(ctx.packageData.Unions))
	printObjNum("message", len(ctx.packageData.Messages))
	fmt.Fprintln(w, "*/")
	fmt.Fprintf(w, "package %s\n", ctx.packageName)
	fmt.Fprintln(w)
}
123922
func (mag MaterialAttributesGit) GenerateGeneric() (ma map[string]interface{}) {
	ma = map[string]interface{}{
		"name":             mag.Name,
		"url":              mag.URL,
		"auto_update":      mag.AutoUpdate,
		"branch":           mag.Branch,
		"submodule_folder": mag.SubmoduleFolder,
		"destination":      mag.Destination,
		"shallow_clone":    mag.ShallowClone,
		"invert_filter":    mag.InvertFilter,
	}
	if f := mag.Filter.GenerateGeneric(); f != nil {
		ma["filter"] = f
	}
	return
}
540750
func (sd structDef) generate(dir string) error {
	// generate enums
	for _, f := range sd.Fields {
		if f.Enum != nil {
			if err := f.Enum.generate(dir); err != nil {
				return err
			}
		}
	}
	if sd.Enum != nil {
		return sd.Enum.generate(dir)
	}
	fileName := filepath.Join(dir, sd.Name+".go")
	return commons.GenerateFile(sd, structTemplateLocation, "struct_template", fileName, true)
}
399391
func Generate() (files []string, err error) {
	var (
		outDir, designPkg, appPkg, ver, res, pkg string
		force, regen                             bool
	)

	set := flag.NewFlagSet("controller", flag.PanicOnError)
	set.StringVar(&outDir, "out", "", "")
	set.StringVar(&designPkg, "design", "", "")
	set.StringVar(&appPkg, "app-pkg", "app", "")
	set.StringVar(&pkg, "pkg", "main", "")
	set.StringVar(&res, "res", "", "")
	set.StringVar(&ver, "version", "", "")
	set.BoolVar(&force, "force", false, "")
	set.BoolVar(&regen, "regen", false, "")
	set.Bool("notest", false, "")
	set.Parse(os.Args[1:])

	if err := codegen.CheckVersion(ver); err != nil {
		return nil, err
	}

	g := &Generator{OutDir: outDir, DesignPkg: designPkg, AppPkg: appPkg, Force: force, Regen: regen, API: design.Design, Pkg: pkg, Resource: res}

	return g.Generate()
}
434424
func (g *genDeepCopy) generateFor(t *types.Type, sw *generator.SnippetWriter) {
	// derive inner types if t is an alias. We call the do* methods below with the alias type.
	// basic rule: generate according to inner type, but construct objects with the alias type.
	ut := underlyingType(t)

	var f func(*types.Type, *generator.SnippetWriter)
	switch ut.Kind {
	case types.Builtin:
		f = g.doBuiltin
	case types.Map:
		f = g.doMap
	case types.Slice:
		f = g.doSlice
	case types.Struct:
		f = g.doStruct
	case types.Pointer:
		f = g.doPointer
	case types.Interface:
		// interfaces are handled in-line in the other cases
		klog.Fatalf("Hit an interface type %v. This should never happen.", t)
	case types.Alias:
		// can never happen because we branch on the underlying type which is never an alias
		klog.Fatalf("Hit an alias type %v. This should never happen.", t)
	default:
		klog.Fatalf("Hit an unsupported type %v.", t)
	}
	f(t, sw)
}
961083
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
}