qparam

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 5 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 qparam normalizes URL query-parameter values before they hit the wire.

Covers `@EpochMillis` timestamp fields: the public API accepts millisecond- epoch integers (Long on the JVM side), but humans and agents prefer ISO-8601 ("2026-04-01T00:00:00Z" or "2026-04-01"). MaybeDate detects parameters and body fields that the spec marks with `format: "date-time-millis"` and converts ISO-8601 inputs to millisecond strings; numeric inputs pass through unchanged.

The set of recognized date-keyed names is loaded at startup from the embedded OpenAPI spec via SetDateKeys — there is no hardcoded suffix list, so any new `@EpochMillis` field added on the backend automatically picks up coercion as soon as `make spec` regenerates the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoerceBodyDates added in v0.3.7

func CoerceBodyDates(payload interface{}) error

CoerceBodyDates walks a JSON-shaped value tree and rewrites every timestamp-shaped field (per IsDateParam) from ISO-8601 to epoch-millis as a string. Mirrors what compactQuery does for URL query params; lets the CLI-generated write path (cligen-emitted body.Compose calls) accept ISO-8601 in `--params.expiresAt` flags and the MCP path accept it in JSON body values, both transparently.

Recurses into nested maps and arrays; mutates in place. No-op on nil or non-object roots — safe to call after Compose returned a typed Go scalar.

func IsDateParam added in v0.3.7

func IsDateParam(name string) bool

IsDateParam reports whether the parameter / field name carries a timestamp, per the spec-driven registry populated by SetDateKeys.

func MaybeDate

func MaybeDate(name, value string) (string, error)

MaybeDate coerces a value if the param name implies a timestamp.

  • All-digit input is treated as already-epoch-millis and passed through.
  • ISO-8601 ("2026-04-01T00:00:00Z", "2026-04-01T00:00:00.123Z", "2026-04-01") is parsed and converted to millis.
  • Anything else returns a wrapped error naming the offending param.

Non-date params return the input unchanged.

func SetDateKeys added in v0.3.7

func SetDateKeys(set map[string]bool)

SetDateKeys registers the set of field/parameter names whose values should be coerced from ISO-8601 to epoch-millis. Idempotent — call once at startup with the union of body-property names + query-parameter names extracted from the spec.

Pass an empty/nil map to disable coercion entirely (mainly useful in tests that exercise the raw passthrough path).

func ValidateEnum added in v0.3.8

func ValidateEnum(name, raw string, allowed []string, repeat bool) error

ValidateEnum rejects raw values that aren't members of allowed.

`repeat` true means the flag accepts a comma-separated list (the OpenAPI array shape, e.g. `--statuses signing-required,waiting-approval`); each element is checked individually. False means a single scalar.

Empty value is always valid — the flag is unset and the param won't be sent. Unknown elements produce a single error with the offending value and the full allowed list, so the user sees the fix in one read.

Types

This section is empty.

Jump to

Keyboard shortcuts

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