Exemplo n.º 1
0
// NewUserTypesWriter returns a contexts code writer.
// User types contain custom data structured defined in the DSL with "Type".
func NewUserTypesWriter(filename string) (*UserTypesWriter, error) {
	file, err := codegen.SourceFileFor(filename)
	if err != nil {
		return nil, err
	}
	return &UserTypesWriter{
		SourceFile: file,
		Finalizer:  codegen.NewFinalizer(),
		Validator:  codegen.NewValidator(),
	}, nil
}
Exemplo n.º 2
0
import (
	"github.com/goadesign/goa/design"
	"github.com/goadesign/goa/goagen/codegen"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Struct finalize code generation", func() {
	var (
		att       *design.AttributeDefinition
		target    string
		finalizer *codegen.Finalizer
	)

	BeforeEach(func() {
		finalizer = codegen.NewFinalizer()
	})

	Context("given an object with a primitive field", func() {
		BeforeEach(func() {
			att = &design.AttributeDefinition{
				Type: &design.Object{
					"foo": &design.AttributeDefinition{
						Type:         design.String,
						DefaultValue: "bar",
					},
				},
			}
			target = "ut"
		})
		It("finalizes the fields", func() {