ISSUE DESCRIPTION Generator: emit resolveBaseURL when URL fields contain placeholders…
- User
ISSUE DESCRIPTION
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.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
- Assistant
I'll start by exploring the repository structure and the relevant spec code to understand how endpoint template vars and URL fields are currently handled.
- Assistant
Next I'll inspect
spec.goand search forEndpointTemplateVarsand generator initialization. - Assistant
rg is not available, I'll use grep instead.
- Assistant
I'll open the EndpointTemplateVars section of
spec.goand checkGenerator.Newnext. - Assistant
I'll read
Generator.Newand look for any existing inference helpers or related tests/docs. - Assistant
There's existing path-param parsing — I'll inspect that and how
resolveBaseURLis generated. - Assistant
Let me look at url.go templates and uname patterns for map ordering patterns used in the codebase. Also check AGENTS.md for relevant guidance.
- Assistant
Checking for stubs and reading
url.go.tmpl, plus scanning tier-routing validation of base-url placeholders. - Assistant
I'll inspect validation around template vars and open the tier-routing plan section that mentions collecting placeholders.
- Assistant
I'll search for sorting helpers and any unfinished work related to this feature.
- Assistant
Let me look at the openapi parser for how it extracts template vars from base URLs - this might be similar logic.
- Assistant
Checking how generation refers to URL resolution and whether
Generator.Newshould call other inference methods. - Assistant
Let me look at the end of Generator.New to see where to add the call, and also check if EnrichPathParams is called somewhere.
- Assistant
Let me look at Generator.New around line 565 where it returns, and LoadYAML at 1761.
- Assistant
Checking for existing key-sort helpers and required nil-safety in the package.
- Assistant
Implementing
InferEndpointTemplateVarsFromBaseURLsand wiring it intoGenerator.Newand the YAML load path. - Assistant
Inserting the inference method after
IsEndpointTemplateVar. - Assistant
There's a duplicate return line — fixing that next.
- Assistant
Wiring the inference call into
Generator.Newand the YAML load path. - Assistant
Adding the inference call to the YAML load path before validation.
- Assistant
I'll add InferEndpointTemplateVarsFromBaseURLs after EnrichPathParams.
- Assistant
Writing a temporary script to verify inference order, dedupe, and Generator.New integration.
- Assistant
I'll rename the temp script so
go runaccepts it. - Assistant
I'll put a temporary main under the module so it can import internal packages.
- Assistant
Inference looks good — next I'll confirm generation emits a buildable client with URL resolution for a templated base URL.
- Assistant
Generation and build succeeded. Cleaning up temp files and running relevant package tests.
- Assistant
Running focused generator tests related to EndpointTemplateVars.
- Assistant
Checking whether generated code names the helper
resolveBaseURLanywhere: - Assistant
Adding a blank line between the helpers for style consistency.
- Assistant
I'll add a blank line after sortedStringKeys.
- Assistant
Verifying the final diff and that the workspace is clean of temp files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.