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
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- Assistant
I’ll inspect the repository structure and locate the specification model, generator initialization, and existing URL/template handling. Then I’ll implement inference with deterministic map traversal, wire it into
Generator.New, run focused and broader tests, and review the final diff. - Assistant
The repository already has runtime resolver support keyed by
EndpointTemplateVars; the missing piece appears to be populating that slice from URL fields. I’ll now inspect all relevant spec types and existing validation/parser behavior so the new method covers the complete documented field graph without changing explicit-variable semantics. - Assistant
The model confirms the URL-bearing fields and nested maps:
TierRouting.Tiers, resources, endpoints, and recursively nested subresources. I’ll use the same identifier grammar as the existing OpenAPI/runtime placeholder handling, preserve the current slice verbatim, and traverse each map by sorted keys. The inference call will be the first operation ingenerator.New, ensuring callers see the mutation immediately. - Assistant
The implementation is in place and formatted. It scans top-level fields first, then sorted tiers, then recursively sorted resources/endpoints/subresources; repeated placeholders are suppressed while explicit slice entries remain untouched. I’ll run focused package tests and a small temporary executable/test-like check for ordering and
Newmutation, then the broader suite if feasible. - Assistant
The code test command was blocked by the environment before compilation: Go reports neither
GOMODCACHEnorGOPATHis configured, so the temporary check was not created. I’ll inspect available Go paths/cache and rerun with an appropriate local cache setting, without modifying repository tests. - Assistant
Focused tests show
internal/spec,internal/openapi, andinternal/graphqlpass, while the generator package fails only because an existing generated-client vulnerability gate detects the installed Go standard-library vulnerability (GO-2026-5856), unrelated to this change. I’ll perform a direct runtime check from within the module and run generator tests with the vulnerability-gated test excluded, then inspect status for unintended changes. - Assistant
The direct check produced the expected deterministic result and the focused generator tests passed. The test run polluted the repository’s tracked
.gocachedirectory because it had to be used asGOCACHE; I’ll clean and restore that cache directory, verify only the two intended source files remain changed, and then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.