Help us shape the future of Go! Take the 2026 Go Developer Survey

frank

package
v0.0.87 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 20 Imported by: 4

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"`
}

Auth represents authentication configuration, discriminated by the Type field. It covers the auth types whose fields are flat: bearer, basic, digest and apikey. oauth2 nests its configuration and differs per flow, so it has its own type.

type AuthConfig added in v0.0.84

type AuthConfig interface {
	// contains filtered or unexported methods
}

AuthConfig is the set of values an auth field can hold. The marker method is unexported, so nothing outside this package can add a variant.

type AuthInherit added in v0.0.84

type AuthInherit struct{}

AuthInherit renders as the string "inherit", the only non-object value OpenCollection accepts for auth.

func (AuthInherit) MarshalYAML added in v0.0.84

func (AuthInherit) MarshalYAML() (any, error)

type AuthOAuth2 added in v0.0.84

type AuthOAuth2 struct {
	Type             string               `yaml:"type"`
	Flow             string               `yaml:"flow"`
	AuthorizationURL string               `yaml:"authorizationUrl,omitempty"`
	AccessTokenURL   string               `yaml:"accessTokenUrl,omitempty"`
	RefreshTokenURL  string               `yaml:"refreshTokenUrl,omitempty"`
	CallbackURL      string               `yaml:"callbackUrl,omitempty"`
	Credentials      *OAuth2Credentials   `yaml:"credentials,omitempty"`
	ResourceOwner    *OAuth2ResourceOwner `yaml:"resourceOwner,omitempty"`
	Scope            string               `yaml:"scope,omitempty"`
	State            string               `yaml:"state,omitempty"`
	Settings         *OAuth2Settings      `yaml:"settings,omitempty"`
}

AuthOAuth2 represents an oauth2 auth block. Each flow permits a different set of fields and OpenCollection rejects any it does not recognise, so the mapper sets only the ones its flow allows.

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 AuthConfig `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 FormField added in v0.0.84

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

type FormUrlEncodedBody added in v0.0.84

type FormUrlEncodedBody struct {
	Type string      `yaml:"type"`
	Data []FormField `yaml:"data"`
}

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 MultipartField added in v0.0.84

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

MultipartField's type is either text or file.

type MultipartFormBody added in v0.0.84

type MultipartFormBody struct {
	Type string           `yaml:"type"`
	Data []MultipartField `yaml:"data"`
}

type OAuth2Credentials added in v0.0.84

type OAuth2Credentials struct {
	ClientID     string `yaml:"clientId,omitempty"`
	ClientSecret string `yaml:"clientSecret,omitempty"`
	Placement    string `yaml:"placement,omitempty"`
}

OAuth2Credentials holds the client credentials. The implicit flow accepts only clientId, so the other two fields stay empty there.

type OAuth2ResourceOwner added in v0.0.84

type OAuth2ResourceOwner struct {
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

OAuth2ResourceOwner holds the end-user credentials for the password flow.

type OAuth2Settings added in v0.0.84

type OAuth2Settings struct {
	AutoFetchToken   bool `yaml:"autoFetchToken"`
	AutoRefreshToken bool `yaml:"autoRefreshToken"`
}

OAuth2Settings controls Bruno's token handling.

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 RawBody added in v0.0.84

type RawBody struct {
	Type string `yaml:"type"`
	Data string `yaml:"data"`
}

RawBody's type is one of json, text, xml or sparql.

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 interface {
	// contains filtered or unexported methods
}

RequestBody is the set of body shapes OpenCollection accepts. A raw body carries its payload as text and the others carry a list of fields, so no single struct holds them all.

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    AuthConfig      `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