Skip to content

Dynamic variable parity: $timestamp offsets, $localDatetime and the $random.* family #34

Closed

Description

@dataGriff

Why

apic's built-ins (internal/runner/vars.go:129-189) cover $uuid, $timestamp, $isoTimestamp, $datetime, $randomInt, $processEnv, $dotenv and $env.X. REST Client files also use offsets ({{$timestamp -1 d}}, {{$datetime iso8601 1 h}}) and {{$localDatetime}}; JetBrains files use $random.integer(1, 100), $random.alphabetic(10), $random.email and friends. Those files currently fail with a missing-variable error under apic.

What

Acceptance criteria:

  • $timestamp [offset unit] and $datetime <format> [offset unit] accept the REST Client offset grammar (-1 d, 2 h, 30 m, -10 s, 1 w, 1 M, 1 y).
  • $localDatetime [format] formats in the local zone with the same options as $datetime.
  • JetBrains: $random.integer(min, max), $random.float(min, max), $random.alphabetic(n), $random.alphanumeric(n), $random.hexadecimal(n), $random.email, $random.uuid. Argument-less forms take the JetBrains defaults.
  • $exampleServer is deliberately not added (JetBrains-only concept); $projectRoot resolves to the apic project root since it is cheap and useful for < {{$projectRoot}}/fixtures/x.json.
  • The nesting cap of 8 (vars.go:76-78) still applies; the random functions are not nonces and keep the existing //nolint:gosec reasoning.

Where

internal/runner/vars.go; internal/runner/runner_test.go.

Docs

docs/format.md (Built-ins table), docs/cheatsheet.md (Built-in placeholders).

Tests

A table-driven test per function, with a fixed clock injected for the time-based ones; a parse-error test for a bad offset that names the placeholder and the line.

Activity

  1. dataGriff commented on Sep 22, 2026

    @dataGriff
    OwnerAuthor

    Shipped in #108 (merged as 1c7ba70): offsets on $timestamp and $datetime (-1 d, 2 h, 1 M, 1 Q, 1 y, …), $localDatetime [format] [offset], the JetBrains $random.integer/float/alphabetic/alphanumeric/hexadecimal/email/uuid family with defaults, and $projectRoot; a bad offset is a usage error naming the placeholder and line. See internal/runner/vars.go; the tests pin the runner's clock.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions