params

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package params resolves parameter values (FR-PARAM-01/02) and serializes them according to the OpenAPI style rules (FR-PARAM-07).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeQuery

func EncodeQuery(pairs []Pair) string

EncodeQuery builds a query string from pairs, keeping their order.

func Generated

func Generated(s *openapi3.Schema) (any, bool)

Generated is a plain value that fits schema s, for a parameter nothing else gives a value: its default or first enum value, else by type and format within the limits of the schema. ok is false if none fits (e.g. a pattern the value does not match).

func Header(p *openapi3.Parameter, v any) (string, error)

Header serializes a header parameter value (style simple).

func Path

func Path(p *openapi3.Parameter, v any) (string, error)

Path serializes a path parameter value (styles simple, label, matrix). The result is already escaped for use in a URL path.

func Scalar

func Scalar(v any) string

Scalar formats a primitive value the same way parameters are serialized.

Types

type Inputs

type Inputs struct {
	CaseName string            // example name of the case, e.g. "valid-planet"
	Fixed    map[string]string // Config.Params
	OpID     string            // operation of the case, for "<operationId>.<name>" keys
	// Binding returns a bound value for a parameter, if any (rank 1).
	Binding func(p *openapi3.Parameter) (any, bool)
	// Override sets path parameters by name before any other source: the
	// unknown key of a not-found case.
	Override map[string]any
	// Generate gives a required parameter no source has a value for one
	// derived from its schema (Generated), e.g. the parent key of a
	// not-found case whose producer did not run.
	Generate bool
}

Inputs are the sources that depend on the run rather than on the spec.

type Pair

type Pair struct {
	Key, Value string
}

Pair is one serialized query parameter or cookie.

func Cookie(p *openapi3.Parameter, v any) (Pair, error)

Cookie serializes a cookie parameter (style form).

func Query

func Query(p *openapi3.Parameter, v any) ([]Pair, error)

Query serializes a query parameter into key/value pairs (styles form, spaceDelimited, pipeDelimited, deepObject). Values are not yet escaped.

type Rank

type Rank int

Rank is the source of a parameter value, in order of precedence.

const (
	RankNone          Rank = iota
	RankBinding            // 1: value from an earlier response
	RankFixed              // 2: Config.Params
	RankNamedExample       // 3: named example with the case's name
	RankExample            // 4: example of the parameter
	RankSchemaExample      // 5: example/examples[0] of the schema
	RankDefault            // 6: default of the schema
	RankEnum               // 7: first enum value
	RankGenerated          // 8: generated from the schema (Inputs.Generate)
)

Ranks in order of precedence (see "How it works" in the README).

func (Rank) String

func (r Rank) String() string

type Value

type Value struct {
	V    any
	Rank Rank
}

Value is a resolved parameter value.

func Resolve

func Resolve(p *openapi3.Parameter, in Inputs) (Value, bool)

Resolve determines the value of p. ok is false if no source provides a value, or if p is optional and only a schema-level source would (FR-PARAM-02).

Jump to

Keyboard shortcuts

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