Skip to content

Commit 4e0c41b

Browse files
tadeleshgithub-actions[bot]CopilotCopilot
authored
[Automated][tcgc] Document server URL template parameter API version detection (#4416)
Update versioning docs to explain that name-based API version detection applies to both HTTP metadata parameters and server URL template parameters declared in @server. This documents the fix from PR #4341 regression where server URL template params named apiVersion/api-version were not recognized. Also update knowledge base with lessons from PR #4398 feedback. Resolve: #4404 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
1 parent 1608b64 commit 4e0c41b

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

eng/scripts/doc-updater/knowledge/tcgc.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ namespace (@clientNamespace), naming (@clientName), overload, structure (@client
143143
- Don't add Spector specs for code-generation controls like @convenientAPI/@protocolAPI — they aren't testable at the HTTP wire level.
144144
- The `@deserializeEmptyStringAsNull` section was removed from 08types.mdx in feedback PR #4268. Don't re-add it unless specifically requested.
145145
- Spector response-as-bool spec needs BOTH a success (200) case AND a 404 case to be complete.
146+
- TypeSpec examples in docs with operations MUST include `@route` decorators to be valid TypeSpec (feedback PR #4398).
147+
- In @hierarchyBuilding language examples: each language handles inheritance differently. Python doesn't use real hierarchy (copies all props to each class). Go uses flat structs. C# and TypeScript use real inheritance. Java uses class inheritance.
148+
- C# property names that conflict with their enclosing class name should use a suffix (e.g., `CProperty` not `C` for a property in class `C`).
149+
- The "Body Model Properties Named apiVersion" section was removed from 10versioning.mdx during review (PR #4398) — don't re-add as a separate section. The behavior is covered implicitly by the main description.
146150

147151
## @responseAsBool Internal Design
148152

@@ -171,4 +175,5 @@ namespace (@clientNamespace), naming (@clientName), overload, structure (@client
171175
- Readonly properties have Input flag stripped but other flags (Output, Json, Xml) still propagate through.
172176
- External types (via @alternateType with ExternalTypeInfo) block propagation of all non-External flags.
173177
- `@apiVersion(false)` prevents a parameter from matching to a client API version parameter, keeping it on the method.
174-
- Body model properties named "apiVersion" are NOT treated as API version params — only HTTP metadata params (header/query/path/cookie) are matched by name.
178+
- Body model properties named "apiVersion" are NOT treated as API version params — only HTTP metadata params (header/query/path/cookie) and server URL template parameters (from `@server`) are matched by name.
179+
- Server URL template parameters (declared in `@server` decorator's parameter model) named `apiVersion`/`api-version` are recognized as API version params, even with plain `string` type in versioned services.

eng/scripts/doc-updater/knowledge/tcgc.meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"lastCommit": "3c44dbcd32aa0bbe051f048c585dc84b6f7f37f0",
3-
"lastUpdated": "2026-05-04T10:55:59.245Z",
2+
"lastCommit": "5849136c72dc8034af0c6e6f0c44a2843bf2ef2e",
3+
"lastUpdated": "2026-05-11T10:59:26.562Z",
44
"analyzedPaths": [
55
"packages/typespec-client-generator-core/src",
66
"packages/typespec-client-generator-core/lib",

website/src/content/docs/docs/howtos/Generate client libraries/10versioning.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,9 @@ func (client *ServiceClient) GetUserInfo(ctx context.Context, userInfo UserInfo,
829829

830830
## Overriding the Client Api Version Parameter
831831

832-
By default, we find api version parameters in specs based off of names. There is special logic we do with api version parameters:
832+
By default, we find api version parameters in specs based off of names. Name-based detection applies to HTTP metadata parameters (header, query, path, or cookie) and server URL template parameters (declared in `@server`). A parameter named `apiVersion` or `api-version` in these positions will automatically be treated as an API version parameter.
833+
834+
There is special logic we do with api version parameters:
833835

834836
1. These api version parameters get elevated up to the client level (if the service is versioned)
835837
2. We auto-add api version information to next links when paging

0 commit comments

Comments
 (0)