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
Now let me look at the existing generator test for template vars to mirror its style:
- Assistant
Now wire it into
Generator.New: - Assistant
Now add tests. First check the spec test file style:
- Assistant
Now add the generator test. Let me find where
TestGenerateEndpointTemplateVarsRuntimeSubstitutionends: - Assistant
Many failures — some may relate to my change, some may be resource exhaustion (I saw
fork/exec ... resource temporarily unavailable). Let me run the suspicious one directly: - Assistant
They pass individually — the mass failures were resource exhaustion during the fully parallel run. Let me run the affected packages one at a time:
- Assistant
Confirmed pre-existing. Now run the generator package fully and list all failures:
- Assistant
Also a parallelism flake. Run the remaining packages with bounded parallelism:
- Assistant
Both remaining failures are pre-existing on a clean tree. Now run the golden harness, since generation behavior could shift:
- Assistant
That's suspiciously broad. Check whether golden verify fails on the clean tree too:
- Assistant
Identical failure sets — all 94 golden failures are pre-existing environment noise, and my change adds zero new diffs. Let me peek at one pre-existing diff to confirm the cause:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.