Skip to content

Tag↔group PascalCase collision causes unnecessary '2' suffixes on sub-clients #207

@HavenDV

Description

@HavenDV

Problem

When an OpenAPI spec has both tags and x-fern-sdk-group-name extensions that resolve to the same PascalCase name, AutoSDK adds 2 suffixes to sub-client class names to resolve the "collision" — even though the original tag ends up with zero assigned methods and should be filtered out.

Example: Vectara SDK

The Vectara spec has:

  • OpenAPI tag: "Corpora"
  • x-fern-sdk-group-name: corpora on all operations tagged with "Corpora"

With UseExtensionNaming=true (default), AutoSDK:

  1. Collects all OpenAPI tags → ["Corpora", "Encoders", "Rerankers", ...]
  2. Scans x-fern-sdk-group-name values → adds ["corpora", "encoders", "rerankers", ...] as ad-hoc tags
  3. Both "Corpora" and "corpora" resolve to PascalCase Corporacollision detected → suffix 2 added
  4. Operations are reassigned from tag "Corpora" to group "corpora" → tag "Corpora" ends up empty
  5. Empty tags are filtered out — but the collision was already resolved with the 2 suffix

Result: Corpora2Client, Encoders2Client, Rerankers2Client, Agents2Client, etc.

Expected Behavior

AutoSDK should resolve naming collisions after filtering out empty tags (tags that lost all their operations to x-fern-sdk-group-name reassignment). Since the original tag "Corpora" has zero methods after reassignment, it should be removed before collision detection runs, and the group "corpora" should produce a clean CorporaClient.

Current Workaround

Strip x-fern-sdk-group-name and x-fern-sdk-method-name from the spec in generate.sh:

python3 -c "
import re, sys
with open('openapi.yaml') as f:
    lines = f.readlines()
out = []
for line in lines:
    stripped = line.strip()
    if stripped.startswith('x-fern-sdk-group-name:') or stripped.startswith('x-fern-sdk-method-name:'):
        continue
    out.append(line)
with open('openapi.yaml', 'w') as f:
    f.writelines(out)
"

Note: This is fragile — it doesn't handle YAML list-style values like:

x-fern-sdk-group-name:
- auth

A proper YAML parser (PyYAML) is needed for robust stripping.

Affected SDKs

Any SDK whose spec uses Fern-generated x-fern-sdk-group-name values that match the OpenAPI tag names in PascalCase. Currently known: Vectara.

Suggested Fix

In Data.cs, move the collision resolution step to after the empty-tag filtering step. The flow should be:

  1. Collect tags + ad-hoc groups
  2. Reassign operations based on x-fern-sdk-group-name
  3. Filter out empty tags (tags with zero assigned methods)
  4. Then resolve PascalCase naming collisions among remaining tags/groups

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions