Support per-service api-version mapping for multi-service specs#4594
Support per-service api-version mapping for multi-service specs#4594Copilot wants to merge 3 commits into
Conversation
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Audited all |
The
api-versionemitter option only accepted a single string, which is silently ignored for multi-service specs and could produce incorrectly-projected SDKs. This extends it to accept a per-service mapping.api-versionnow accepts either:string— applies only to single-service specs (unchanged).dict— maps each service namespace to a version; services not listed default to their latest version. A service may be mapped toallto keep all of its versions.Changes
"api-version"is nowstring | Record<string, string>; JSON schema updated to["string", "object"]withoneOf.resolveApiVersionForNamespace(context, namespace, multiService), the single source of truth for the effective version of a service. Returnsundefined(→ use latest) for the multi-service string case and for unmapped services.removeVersionsLargerThanExplicitlySpecified), decorator filtering (filterApiVersionsWithDecorators), preview filtering (filterPreviewVersion), package-version caching,handleVersioningMutationForGlobalNamespace, andgetDefaultApiVersion.TCGCContext.apiVersionusages — the remaining directcontext.apiVersion === "all"comparisons inpackage.ts(building theapiVersionsmap and the deprecated single-serviceapiVersionmetadata) now go throughresolveApiVersionForNamespace, so per-service mappings — including a per-serviceall— are honored.all—handleVersioningMutationForGlobalNamespaceskips the versioning mutation for any service whose resolved version isall, keeping all of that service's versions. The global stringallearly-return is preserved for both single- and multi-service specs.api-version-undefinedis now reported per service when a mapped version doesn't exist, instead of only for the single-service case.Notes
handleVersioningMutationForGlobalNamespaceno longer mutatescontext.apiVersionas a side channel (previously set toundefinedfor multi-service and to the latest version on invalid input); the resolution/fallback now happens explicitly at each use site.latestversions continue to fall back to the latest version. A global stringallkeeps all versions across every service, and a per-serviceallmapping keeps all versions for that specific service.