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 ¶
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 ¶
IsDateParam reports whether the parameter / field name carries a timestamp, per the spec-driven registry populated by SetDateKeys.
func MaybeDate ¶
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.
- Relative "now", "now-<N><unit>" and "-<N><unit>" (unit s/m/h/d/w) resolve against the current UTC time to a past instant.
- Anything else returns a wrapped error naming the offending param.
Non-date params return the input unchanged.
func SetDateKeys ¶
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 ¶
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.