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 tests to understand test patterns for template vars:
- Assistant
Now I'll implement the method in
internal/spec/spec.go. Adding it afterIsEndpointTemplateVar: - Assistant
Now wire it into
Generator.New: - Assistant
Build passes. Now let me add tests. First, check the spec test file style:
- Assistant
Now add a spec-level test:
- Assistant
Transient fork failure — retrying:
- Assistant
Now add a generator-level test. Let me check how existing compile-tests are gated:
- Assistant
Now run the full test suite and the golden verify:
- Assistant
Passes in isolation — the full-suite failures may be resource contention. Let me run the affected package fully:
- Assistant
All batch failures are
fork/exec: resource temporarily unavailable— sandbox process limits when many generated-CLI compile subprocesses run in parallel, not code failures. Let me run with constrained parallelism: - Assistant
This is a stdlib vulnerability flagged by govulncheck against the installed toolchain — let me confirm it's pre-existing:
- Assistant
Let me check whether these golden failures are pre-existing on the clean tree:
- Assistant
Identical failure sets — all 94 pre-existing. Let me peek at one diff to confirm the pre-existing cause isn't masking a diff from my change:
- Assistant
Final targeted verification of the template-var test cluster (byte-compat guard included):
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.