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 specification model and generator initialization/validation flow, identify all URL-bearing fields and existing template-variable handling, then implement deterministic inference and integrate it into
Generator.New. I’ll run focused tests (and the broader relevant suite if practical), verify generated behavior, and review the final diff before submission. - Assistant
The relevant model already has all requested fields, and
Generator.Newcurrently returns a generator without mutating template variables. I’ll add a receiver method ininternal/spec/spec.gothat scans fields in a documented, stable order: top-level fields, sorted tier keys, then recursively sorted resource/endpoint/subresource keys. It will seed a set from the existing slice so explicit entries (including their ordering) remain untouched, while only newly encountered tokens are appended.Newwill invoke it before any generator setup. - Assistant
The implementation is in place and formatted. One subtle documentation placement issue was corrected so the exported method comments attach properly. The first test attempt was blocked by the environment having neither
GOMODCACHEnorGOPATH; I’ll retry with a temporary module cache, then use a small temporary Go test program if dependency installation remains unavailable. - Assistant
Focused validation now passes:
internal/spectests pass and the generator package compiles. The broader generator test run reached an unrelated repository vulnerability gate failure (GO-2026-5856in the installed Go standard library), while OpenAPI and GraphQL packages passed. I’ll do a final diff review 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.