Documentation
¶
Overview ¶
Package generator writes a Go SDK package from a service's definitions, the way Pandora's generator-go-sdk writes go-azure-sdk: it reads nothing but the definitions, and every decision it makes about the API was already made by the importer.
One package per server (BaseItemDto is everywhere, so per-tag packages would all import one another), laid out by tag in file names:
client.go Client and New
client_test.go the canned server the tests share
doc.go the package documentation
<tag>_method_<operation>.go one per operation: the method, its
<Name>OperationResponse, its
<Name>OperationOptions, and for list
operations a <Name>Complete pager
<tag>_method_<operation>_test.go the operation's test (tests.go)
<tag>_model_<model>.go one per model
<tag>_constants.go the tag's enums
Requests go through a base client, named in Options.ClientImport: pandorest's own (the client package), which this package's tests build and run a generated package against, or one a repository keeps of its own, with what the README says generated code calls.
Index ¶
Constants ¶
const Header = "// Code generated by pandorest; DO NOT EDIT.\n"
Header starts every generated file.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(svc *definitions.Service, dir string) (int, error)
Check verifies that the package in dir has a method on Client for every operation in the definitions (and a Complete method for every list), and returns how many operations it found.
func Generate ¶
func Generate(svc *definitions.Service, opts Options) (int, error)
Generate writes the package and removes generated files it no longer produces. It returns the number of files written.
Types ¶
type Options ¶
type Options struct {
// Dir is the package directory.
Dir string
// Definitions is the definitions directory, named in the package doc.
Definitions string
// Version is the version the document's file is named by, which the
// package declares as DocumentVersion; empty declares none.
Version string
// ClientImport is the import path of the base client the package sends
// its requests through.
ClientImport string
// Client, when set, is the source of client.go after its APIVersion
// constant, in place of the default (see config.Service.Client).
Client string
// ClientService, when set, names the client.Service in the package
// that the default client.go makes its client from.
ClientService string
// Notes is a paragraph added to the package documentation.
Notes string
}
Options says where a service's package goes, where it came from and what it is built on.