Documentation
¶
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 and endpoints which wrap the service methods.
- A `views` package that contains code to render a result type using a view.
- transport specific packages for each of the transports defined in the design.
- An example implementation of the client, server, and the service.
OpenAPI ¶
The OpenAPI generator generates an OpenAPI 3.1 specification for the service REST endpoints. This generator requires the design to define the HTTP transport.
Index ¶
- func Example(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- func Generate(dir, cmd, designPackage string, debug bool) (outputs []codegen.Artifact, err1 error)
- func OpenAPI(_ string, roots []eval.Root) ([]*codegen.File, error)
- func Service(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- func TestScaffold(genpkg string, roots []eval.Root) ([]*codegen.File, error)
- func Transport(genpkg string, roots []eval.Root) ([]*codegen.File, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Example ¶
Example iterates through the roots and returns files that implement an example service, server, and client.
func Generate ¶
Generate renders the command output and returns each written artifact with its write intent. designPackage is the canonical import path of the evaluated design that owns the output. Callers installing staged output must apply SkipExist to the live destination rather than treating every rendered path as replaceable.
func OpenAPI ¶
OpenAPI iterates through the roots and returns the files needed to render the service OpenAPI spec. It produces OpenAPI specifications only if the roots define a HTTP service.
func Service ¶
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 Loom design.
func TestScaffold ¶ added in v1.8.0
TestScaffold returns consumer-owned test scaffolds for the evaluated design roots. Existing scaffold files are never overwritten.
Types ¶
This section is empty.