Documentation
¶
Overview ¶
Package frank generates OpenCollection (Bruno v3+) collections from OpenAPI specifications. Named after Frank Bruno, the famous UK boxer — because OpenCollection is Bruno trying to punch out Postman collections.
https://en.wikipedia.org/wiki/Frank_Bruno
Frank is a childhood hero of mine, this is my tribute.
Index ¶
- func RenderBundled(result *FrankResult) ([]byte, error)
- func WriteExploded(baseDir string, files []ExplodedFile) error
- type Auth
- type BrunoConfig
- type BrunoExtensions
- type Collection
- type CollectionAuthor
- type CollectionInfo
- type CollectionItem
- type CollectionRequest
- type Environment
- type EnvironmentVariable
- type ExplodedFile
- type Folder
- type FolderInfo
- type FolderOutput
- type Frank
- type FrankConfig
- type FrankResult
- type ItemInfo
- type OutputMode
- type Request
- type RequestBody
- type RequestHTTP
- type RequestHeader
- type RequestInfo
- type RequestParam
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderBundled ¶
func RenderBundled(result *FrankResult) ([]byte, error)
RenderBundled assembles a FrankResult into a single YAML document with nested items.
func WriteExploded ¶
func WriteExploded(baseDir string, files []ExplodedFile) error
WriteExploded writes the exploded files to a directory.
Types ¶
type Auth ¶
type Auth struct {
Type string `yaml:"type"`
Token string `yaml:"token,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Key string `yaml:"key,omitempty"`
Value string `yaml:"value,omitempty"`
Placement string `yaml:"placement,omitempty"`
GrantType string `yaml:"grantType,omitempty"`
AuthorizationURL string `yaml:"authorizationUrl,omitempty"`
TokenURL string `yaml:"tokenUrl,omitempty"`
CallbackURL string `yaml:"callbackUrl,omitempty"`
Scope string `yaml:"scope,omitempty"`
}
Auth represents authentication configuration, discriminated by the Type field.
type BrunoConfig ¶
type BrunoConfig struct {
Ignore []string `yaml:"ignore,omitempty"`
}
BrunoConfig holds Bruno app configuration.
type BrunoExtensions ¶
type BrunoExtensions struct {
Bruno *BrunoConfig `yaml:"bruno,omitempty"`
}
BrunoExtensions holds Bruno-specific configuration.
type Collection ¶
type Collection struct {
OpenCollection string `yaml:"opencollection"`
Bundled bool `yaml:"bundled,omitempty"`
Info CollectionInfo `yaml:"info"`
Request *CollectionRequest `yaml:"request,omitempty"`
Extensions *BrunoExtensions `yaml:"extensions,omitempty"`
Items []*CollectionItem `yaml:"items,omitempty"`
}
Collection represents the root opencollection.yml file.
type CollectionAuthor ¶
CollectionAuthor identifies a collection author.
type CollectionInfo ¶
type CollectionInfo struct {
Name string `yaml:"name"`
Summary string `yaml:"summary,omitempty"`
Version string `yaml:"version,omitempty"`
Authors []CollectionAuthor `yaml:"authors,omitempty"`
}
CollectionInfo holds metadata about the collection.
type CollectionItem ¶
type CollectionItem struct {
Info ItemInfo `yaml:"info"`
HTTP *RequestHTTP `yaml:"http,omitempty"`
Docs string `yaml:"docs,omitempty"`
Items []*CollectionItem `yaml:"items,omitempty"`
}
CollectionItem represents a folder or request in bundled mode.
type CollectionRequest ¶
type CollectionRequest struct {
Auth *Auth `yaml:"auth,omitempty"`
}
CollectionRequest holds collection-level request defaults.
type Environment ¶
type Environment struct {
Name string `yaml:"name"`
Variables []EnvironmentVariable `yaml:"variables"`
}
Environment represents an environment .yml file.
type EnvironmentVariable ¶
EnvironmentVariable represents a single environment variable.
type ExplodedFile ¶
type ExplodedFile struct {
Path string // relative path, e.g. "users/list-users.yml"
Content []byte
}
ExplodedFile represents a single file in the exploded output.
func RenderExploded ¶
func RenderExploded(result *FrankResult) ([]ExplodedFile, error)
RenderExploded generates exploded output files from a FrankResult.
type Folder ¶
type Folder struct {
Info FolderInfo `yaml:"info"`
}
Folder represents a folder.yml file in the collection tree.
type FolderInfo ¶
FolderInfo holds folder metadata.
type FolderOutput ¶
type FolderOutput struct {
Folder *Folder
Requests []*Request
DirName string // slugified folder name for filesystem
}
FolderOutput holds a folder and its requests in source order.
type Frank ¶
type Frank struct {
// contains filtered or unexported fields
}
Frank implements the Tardis visitor interface to walk a DrDocument and generate an OpenCollection.
To create a new *Frank (which generates a bruno collection), use KnowWhatIMeanArry and pass in a config.
func KnowWhatIMeanArry ¶
func KnowWhatIMeanArry(config *FrankConfig) (*Frank, error)
KnowWhatIMeanArry creates a new Frank generator from config.
func (*Frank) Generate ¶
func (f *Frank) Generate() (*FrankResult, error)
Generate walks the DrDocument and produces a FrankResult.
type FrankConfig ¶
type FrankConfig struct {
DrDoc *model.DrDocument // fully walked DrDocument (required)
OutputMode OutputMode // exploded (default) or bundled
CollectionName string // override info.title
DefaultTag string // folder for untagged ops (default "default")
IncludeDescriptionAsDocs bool // operation.description -> docs field
GenerateEnvironments bool // servers[] -> environment files (always on for OutputExploded)
Logger *slog.Logger
}
FrankConfig configures the Frank generator.
type FrankResult ¶
type FrankResult struct {
Collection *Collection
Environments []*Environment
Folders []*FolderOutput
}
FrankResult holds the output of a Generate() call.
type ItemInfo ¶
type ItemInfo struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Seq int `yaml:"seq"`
Tags []string `yaml:"tags,omitempty"`
}
ItemInfo holds metadata for a bundled collection item.
type OutputMode ¶
type OutputMode int
OutputMode controls how the collection is rendered.
const ( // OutputExploded renders a directory tree (default). OutputExploded OutputMode = iota // OutputBundled renders a single YAML file with nested items. OutputBundled )
type Request ¶
type Request struct {
Info RequestInfo `yaml:"info"`
HTTP RequestHTTP `yaml:"http"`
Docs string `yaml:"docs,omitempty"`
FileName string `yaml:"-"`
}
Request represents a single HTTP request .yml file.
type RequestBody ¶
RequestBody represents the HTTP request body.
type RequestHTTP ¶
type RequestHTTP struct {
Method string `yaml:"method"`
URL string `yaml:"url"`
Params []RequestParam `yaml:"params,omitempty"`
Headers []RequestHeader `yaml:"headers,omitempty"`
Body *RequestBody `yaml:"body,omitempty"`
Auth any `yaml:"auth,omitempty"`
}
RequestHTTP holds the HTTP details for a request.
type RequestHeader ¶
type RequestHeader struct {
Name string `yaml:"name"`
Value string `yaml:"value"`
Disabled bool `yaml:"disabled,omitempty"`
}
RequestHeader represents an HTTP header.