frank

package
v0.0.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 2

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

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

type CollectionAuthor struct {
	Name  string `yaml:"name"`
	Email string `yaml:"email,omitempty"`
}

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

type EnvironmentVariable struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

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

type FolderInfo struct {
	Name string `yaml:"name"`
	Seq  int    `yaml:"seq"`
}

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.

func (*Frank) GetDoctor

func (f *Frank) GetDoctor() v3.Doctor

GetDoctor returns nil — frank doesn't need the doctor.

func (*Frank) Visit

func (f *Frank) Visit(ctx context.Context, object any)

Visit implements the Tardis interface. Only handles Document, Paths, and PathItem.

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

type RequestBody struct {
	Type string `yaml:"type,omitempty"`
	Data string `yaml:"data,omitempty"`
}

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.

type RequestInfo

type RequestInfo struct {
	Name string   `yaml:"name"`
	Type string   `yaml:"type"`
	Seq  int      `yaml:"seq"`
	Tags []string `yaml:"tags,omitempty"`
}

RequestInfo holds request metadata.

type RequestParam

type RequestParam struct {
	Name     string `yaml:"name"`
	Value    string `yaml:"value"`
	Type     string `yaml:"type"`
	Disabled bool   `yaml:"disabled,omitempty"`
}

RequestParam represents a query or path parameter. OC params only support query and path types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL