Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Generator: emit resolveBaseURL when URL fields contain placeholders When an API…

  1. 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 into EndpointTemplateVars before validation and generation so the generated client includes resolveBaseURL support.

    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.New must invoke placeholder inference before it returns, so callers can observe the inferred EndpointTemplateVars immediately 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.

  2. Assistant

    I'll inspect the spec package and generator entry point to see how URL fields and EndpointTemplateVars are defined today.

  3. Assistant

    Implementing placeholder inference and wiring it into Generator.New and Parse.

  4. Assistant

    Adding tests for the inference behavior:

  5. Assistant

    The test expectation was wrong — resources are scanned in sorted name order (alpha before zebra), so I'll fix it.

  6. Assistant

    Implemented placeholder inference for URL-bearing spec fields.

    InferEndpointTemplateVarsFromBaseURLs (internal/spec/spec.go)

    Scans these fields for {placeholder} tokens (using the same identifier regex as the OpenAPI parser and generated buildURL):

    • BaseURL, BasePath, GraphQLEndpointPath
    • Tier BaseURLs (sorted tier names)
    • Resource, endpoint, and subresource BaseURLs (sorted map keys, recursive)

    Behavior:

    • Preserves existing EndpointTemplateVars entries and their order
    • Appends each newly discovered name once
    • Left-to-right order within each URL string

    Call sites

    1. Generator.New — inference runs before return, so callers see populated EndpointTemplateVars immediately and generation uses the same spec.
    2. ParseBytes — inference runs after expandOperations() and before validation, so YAML specs with templated URLs get resolver support without an explicit endpoint_template_vars list.

    Tests

    • TestInferEndpointTemplateVarsFromBaseURLs — preservation, tier/resource scanning, deduplication
    • TestParseInfersEndpointTemplateVarsFromBaseURLs — parse-time inference
    • TestGeneratorNewInfersEndpointTemplateVarsFromBaseURLs — Generator.New inference produces url.go with buildURL and a buildable client

    A spec like base_url: https://{shop} with graphql_endpoint_path: /admin/api/{api_version}/graphql.json now infers ["shop", "api_version"] and emits the URL resolver without hand-declaring endpoint_template_vars.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.