Generator: emit resolveBaseURL when URL fields contain placeholders When an API…
- User
Generator: emit resolveBaseURL when URL fields contain placeholders
When an API specification contains
{PLACEHOLDER}tokens in URL-bearing fields, the generator must infer those placeholder names intoEndpointTemplateVarsbefore validation and generation so the generated client includesresolveBaseURLsupport.Inspect
BaseURL,BasePath,GraphQLEndpointPath, tier base URLs, and resource, endpoint, and subresource base URLs. Preserve existing explicit entries and their order, append each newly discovered placeholder once, and use deterministic ordering when traversing maps. Generation from a templated base URL must produce a buildable client containing the URL resolver.Evaluation contract
Generator.Newmust invoke placeholder inference before it returns, so callers can observe the inferredEndpointTemplateVarsimmediately and later validation/generation uses the same populated specification. Scan every documented URL-bearing field, preserve explicit variables and their order, append each inferred name once, and make map-backed traversal deterministic.Interface
Type: Function Name: InferEndpointTemplateVarsFromBaseURLs Path: internal/spec/spec.go Input: (no parameters) Output: (no return value; mutates receiver's EndpointTemplateVars) Description: Scans the receiver's BaseURL, BasePath, GraphQLEndpointPath, tier BaseURLs, and resource/endpoint/subresource BaseURLs for
{PLACEHOLDER}tokens and appends any newly discovered placeholders to EndpointTemplateVars, preserving existing explicit entries and their order. Call after loading or modifying any URL-bearing field but before validation or code generation. - Assistant
I’ll implement this as a Printing Press generator change, first checking the spec/generator tests and repository state, then adding focused coverage and running formatting, unit tests, and the golden verifier because generated client output is in scope.
- Assistant
rgisn’t installed in this environment, so I’m using localfind/grepinstead. The worktree is clean; external issue operations are unavailable under the no-internet constraint, so I’m proceeding with the requested repository-local fix. - Assistant
The generator already conditionally emits its runtime URL-resolution helper (
buildURL) wheneverEndpointTemplateVarsis non-empty. The missing link is inference: I’m adding it onAPISpec, with stable field/map traversal, and invoking it both during internal-spec parsing (before validation) and at the start ofGenerator.Newfor all parser/caller paths. - Assistant
The implementation and focused tests are in place. Formatting completed; the first test run is still compiling downloaded local module dependencies, after which I’ll address any failures and run the full suite plus golden verification.
- Assistant
The initial compile hit the container’s process limit, not a code failure. I’ve constrained Go’s parallelism; the generated-client build test is now progressing under that limit.
- Assistant
Focused coverage now passes, including compiling a generated CLI from a templated base URL with no explicit variables. The inference test also verifies explicit-order preservation, idempotence, duplicate suppression for inferred names, all requested URL fields, recursive subresources, and sorted traversal of tier/resource/endpoint maps. I’m moving on to repository-wide tests.
- Assistant
The full suite is running cleanly so far under constrained parallelism; no implementation failures have appeared. Generator tests are the slow portion because several cases compile complete printed CLIs.
- Assistant
Repository-wide testing has passed the CLI and crowd-sniff packages and is now in the generator package. The process-limit workaround is stable; I’m letting the full validation finish rather than reducing coverage.
- Assistant
The generator package is still active and CPU-bound compiling its generated fixtures; there is no stalled subprocess or test error. After it completes, the remaining required check is the golden verifier.
- Assistant
The full suite completed with two unrelated environment-sensitive failures: a generated quality-gate test could not run
govulncheck, and an existing pipeline filesystem-walk assertion failed. All spec tests passed. I’ll rerun the failing pipeline test to confirm flakiness, then run the golden verifier and a repository build. - Assistant
I’m rerunning the generator package with fail-fast so its first real assertion is visible without the suite’s many expected warning messages obscuring it. This will distinguish an existing environmental failure from a regression caused by inference.
- Assistant
The generator rerun’s normal output was still too noisy, so I’ve narrowed it to failure records only. This is diagnostic-only and leaves the working tree untouched; the focused changed-path tests remain green.
- Assistant
The generator failure is confirmed unrelated: the installed Go 1.26.4 standard library is flagged by
govulncheckas GO-2026-5856, fixed in Go 1.26.5. The inference/generation test itself passes. I’m now running golden verification and the requested relative-path binary build.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.