Documentation
¶
Index ¶
- Variables
- func AuthTypes() []string
- func Authenticate(req *http.Request, cfg AuthConfig) error
- func IsJSON(mediaType string) bool
- func LoadSpec(filename string) (v3.Document, error)
- func PrettyJSON(json []byte) []byte
- func RunCommand(command string) (string, error)
- func Sanitize(s string) string
- func WriteConfig(filename string, cfg Config) error
- type AuthConfig
- type Config
- type Operation
- type Operations
- type Parameter
- type ParameterList
- type Parameters
- type ProfileConfig
- type RequestValues
- type Result
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is the current version, replaced at build time.
Functions ¶
func AuthTypes ¶ added in v0.6.0
func AuthTypes() []string
AuthTypes returns a list of supported authentication types.
func Authenticate ¶ added in v0.6.1
func Authenticate(req *http.Request, cfg AuthConfig) error
Authenticate authenticates the given request.
func RunCommand ¶ added in v0.6.0
RunCommand runs the given command and returns its output.
The command has access to environment variables.
func WriteConfig ¶
WriteConfig writes the given config to the given filename.
Types ¶
type AuthConfig ¶ added in v0.6.0
type AuthConfig struct { Credentials string `yaml:"credentials"` Command string `yaml:"command"` Type string `yaml:"type"` APIKeyHeader string `yaml:"api_key_header"` }
AuthConfig represents a profile's authentication configuration.
type Config ¶
type Config map[string]ProfileConfig
Config represents Broom's configuration.
func ReadConfig ¶
ReadConfig reads a config file with the given filename.
type Operation ¶
type Operation struct { ID string Summary string Description string Tag string Method string Path string Parameters Parameters BodyFormat string Deprecated bool }
Operation represents an available operation.
func (Operation) SummaryWithFlags ¶ added in v0.6.1
SummaryWithFlags returns the operation summary with flags.
func (Operation) Validate ¶ added in v0.7.0
func (op Operation) Validate(values RequestValues) error
Validate validates the given values against the operation's parameters.
type Operations ¶
type Operations []Operation
Operations represents a list of operations.
func LoadOperations ¶
func LoadOperations(filename string) (Operations, error)
LoadOperations loads available operations from a specification on disk.
func (Operations) ByID ¶
func (ops Operations) ByID(id string) (Operation, bool)
ByID returns an operation with the given ID.
func (Operations) ByTag ¶
func (ops Operations) ByTag(tag string) Operations
ByTag returns a list of operations for the given tag.
func (Operations) Tags ¶
func (ops Operations) Tags() []string
Tags returns a list of all available operation tags.
type Parameter ¶
type Parameter struct { In string Name string Description string Style string Type string Enum []string Example string Default string Deprecated bool Required bool }
Parameter represents an operation parameter.
func (Parameter) CastString ¶
CastString casts the given string to the parameter type.
func (Parameter) FormattedFlags ¶ added in v0.8.0
Flags returns the formatted parameter flags (deprecated, required).
type ParameterList ¶ added in v0.6.1
type ParameterList []Parameter
ParameterList represents a list of parameters.
type Parameters ¶
type Parameters struct { Header ParameterList Path ParameterList Query ParameterList Body ParameterList }
Parameters represents the operation's parameters.
func (*Parameters) Add ¶ added in v0.6.1
func (ps *Parameters) Add(params ...Parameter)
Add adds one or more parameters to the appropriate parameter list.
type ProfileConfig ¶
type ProfileConfig struct { SpecFile string `yaml:"spec_file"` ServerURL string `yaml:"server_url"` Auth AuthConfig `yaml:"auth"` }
ProfileConfig represents Broom's per-profile configuration.
type RequestValues ¶ added in v0.7.0
RequestValues represent the values used to populate an operation request.
Header, query, and body values are added to the request even if they don't have matching parameters, unlike path values, where the parameter is used to determine the name of the placeholder to replace.
func ParseRequestValues ¶ added in v0.7.0
func ParseRequestValues(headers []string, pathValues []string, query string, body string) (RequestValues, error)
ParseRequestValues parses parameter values from the given strings.