Documentation
¶
Overview ¶
Package config handles parsing and loading yapi config files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindUnknownKeys ¶
FindUnknownKeys checks a raw map for keys not in knownV1Keys. Returns a sorted slice of unknown key names.
Types ¶
type ChainStep ¶
type ChainStep struct {
Name string `yaml:"name"` // Required: unique step identifier
ConfigV1 `yaml:",inline"` // All ConfigV1 fields available as overrides
}
ChainStep represents a single step in a request chain. It embeds ConfigV1 so all config fields are available as overrides.
type ConfigV1 ¶
type ConfigV1 struct {
Yapi string `yaml:"yapi"` // The version tag
URL string `yaml:"url"`
Path string `yaml:"path,omitempty"`
Method string `yaml:"method,omitempty"` // HTTP method (GET, POST, PUT, DELETE, etc.)
ContentType string `yaml:"content_type,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
Body map[string]any `yaml:"body,omitempty"`
JSON string `yaml:"json,omitempty"` // Raw JSON override
Query map[string]string `yaml:"query,omitempty"`
Graphql string `yaml:"graphql,omitempty"` // GraphQL query/mutation
Variables map[string]any `yaml:"variables,omitempty"` // GraphQL variables
Service string `yaml:"service,omitempty"` // gRPC
RPC string `yaml:"rpc,omitempty"` // gRPC
Proto string `yaml:"proto,omitempty"` // gRPC
ProtoPath string `yaml:"proto_path,omitempty"`
Data string `yaml:"data,omitempty"` // TCP raw data
Encoding string `yaml:"encoding,omitempty"` // text, hex, base64
JQFilter string `yaml:"jq_filter,omitempty"`
Insecure bool `yaml:"insecure,omitempty"` // For gRPC
Plaintext bool `yaml:"plaintext,omitempty"` // For gRPC
ReadTimeout int `yaml:"read_timeout,omitempty"` // TCP read timeout in seconds
IdleTimeout int `yaml:"idle_timeout,omitempty"` // TCP idle timeout in milliseconds (default 500)
CloseAfterSend bool `yaml:"close_after_send,omitempty"`
// Flow control
Delay string `yaml:"delay,omitempty"` // Wait before executing this step (e.g. "5s", "500ms")
// Expect defines assertions to run after the request
Expect Expectation `yaml:"expect,omitempty"`
// Chain allows executing multiple dependent requests
Chain []ChainStep `yaml:"chain,omitempty"`
}
ConfigV1 represents the v1 YAML schema
type Envelope ¶
type Envelope struct {
Yapi string `yaml:"yapi"`
}
Envelope is used solely to peek at the version
type Expectation ¶
type Expectation struct {
Status any `yaml:"status,omitempty"` // int or []int
Assert []string `yaml:"assert,omitempty"` // JQ expressions that must evaluate to true
}
Expectation defines assertions for a chain step
type ParseResult ¶
type ParseResult struct {
Request *domain.Request
Warnings []string
Chain []ChainStep // Chain steps if this is a chain config
Base *ConfigV1 // Base config for chain merging
Expect Expectation // Expectations for single request validation
}
ParseResult holds the output of parsing a yapi config file.
func Load ¶
func Load(path string) (*ParseResult, error)
Load reads and parses a yapi config file from the given path.
func LoadFromString ¶
func LoadFromString(data string) (*ParseResult, error)
LoadFromString parses a yapi config from raw YAML data.
Click to show internal directories.
Click to hide internal directories.