func (g *Generator) OutputFormatted() (io.Reader, error) {
	out, err := g.Output()
	if err != nil {
		return bytes.NewReader(g.b.Bytes()), err
	}
	var b bytes.Buffer
	if _, err := io.Copy(&b, out); err != nil {
		return bytes.NewReader(g.b.Bytes()), err
	}
	fout, err := imports.Process(
		"opensearchapi/api."+g.Endpoint.Name+".go",
		g.b.Bytes(),
		&imports.Options{
			AllErrors:  true,
			Comments:   true,
			FormatOnly: false,
			TabIndent:  true,
			TabWidth:   1,
		})
	if err != nil {
		return bytes.NewReader(b.Bytes()), err
	}
	g.b.Reset()
	g.b.Write(fout)
	return bytes.NewReader(fout), nil
}
OutputFormatted returns a formatted generator output.
package gensource
import (
	"bytes"
	"fmt"
	"io"
	"reflect"
	"strings"
	"golang.org/x/tools/imports"
	"github.com/opensearch-project/opensearch-go/internal/build/utils"
)
type Generator struct {
	b bytes.Buffer
	Endpoint *Endpoint
}
func (g *Generator) Output() (io.Reader, error) {
	g.genHeader()
	g.genConstructor()
	g.genMethodDefinition()
	g.genRequestStruct()
	g.w("\n")
	g.genDoMethod()
	g.genWithOptions()
	return bytes.NewReader(g.b.Bytes()), nil
}