github.com/goadesign/goa/codegen/generator
generator
import "github.com/goadesign/goa/codegen/generator"
Overview
Package generator contains the code generation algorithms for a service server, client and OpenAPI specification.
Server and Client
The code generated for the service server and client includes:
- A `service' package that contains the declarations for the service
interfaces.
- A `endpoint' package that contains the declarations for the endpoints
which wrap the service methods.
- transport specific packages for each of the transports defined in the
design.
OpenAPI
The OpenAPI generator generates a OpenAPI v2 specification for the service REST endpoints. This generator requires the design to define the HTTP transport.
Index
- Variables
- func Example(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- func Generate(dir, cmd string) ([]string, error)
- func OpenAPI(_ string, roots []eval.Root) (files []*codegen.File, err error)
- func Service(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- func Transport(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- type Genfunc
Package files
docs.go example.go generate.go generators.go openapi.go service.go transport.go
Variables
var Generators = generators
Generators returns the qualified paths (including the package name) to the code generator functions for the given command, an error if the command is not supported. Generators is a public variable so that external code (e.g. plugins) may override the default generators.
func Example
func Example(genpkg string, roots []eval.Root) ([]*codegen.File, error)
Example iterates through the roots and returns files that implement an example service and client.
func Generate
func Generate(dir, cmd string) ([]string, error)
Generate runs the code generation algorithms.
func OpenAPI
func OpenAPI(_ string, roots []eval.Root) (files []*codegen.File, err error)
OpenAPI iterates through the roots and returns the files needed to render the service OpenAPI spec. It returns an error if the roots slice does not include a HTTP root.
func Service
func Service(genpkg string, roots []eval.Root) ([]*codegen.File, error)
Service iterates through the roots and returns the files needed to render the service code. It returns an error if the roots slice does not include a goa design.
func Transport
func Transport(genpkg string, roots []eval.Root) ([]*codegen.File, error)
Transport iterates through the roots and returns the files needed to render the transport code. It returns an error if the roots slice does not include at least one transport design roots.
type Genfunc
type Genfunc func(genpkg string, roots []eval.Root) ([]*codegen.File, error)
Genfunc is the type of the functions invoked to generate code.
Generated by godoc2md