TCGC common models need to support TypeSpec versioning. The support should be separated into two parts:
- Support to get common models from specific version/latest version. This should be applied to all TCGC APIs.
- Support to provide all versioning information for common models that languages' emitter could leverage to generate SDK with version resilency.
- A new option
api-versionwill be added to the TCGC context and should be configed in languages'tspconfig.yamlfile. - If the
api-versionis not set or set tolatest, then all returns of TCGC APIs will be the information of latest API version. - If the
api-versionis set to a specific version, then all returns of TCGC APIs will be the information of that API version. If the version is not existed, then a diagnostic warning will be passed to emitter and will fallback to latest version. - If the
api-versionis set toall, then the returns of TCGC APIs will be the information of all API versions. Next part will describe how the versioning infomation is included in TCGC common models.
createSdkContextandexperimental_sdkPackageinSdkContextgetSdkPackagegetAllModels,getClientTypeand other type conversion functionsgetClient,listClients,listOperationGroups,listOperationsInOperationGroupgetHttpOperationWithCache
NOT GOAL FOR DT
- Provide enought versioning info for emitter to generate version resiliency clients.
- Cover all TypeSpec versioning decorators:
@added,@madeOptional,@removed,@renamedFrom,@returnTypeChangedFrom,@typeChangedFrom. - Only apply to TCGC common models, not decorator/util APIs.
apiVersionsproperty It could cover@addedand@removeddecorators. This property is added to TCGC types according to different TypeSpec types:
Model->SdkModelTypeModelProperty->SdkModelPropertyTypeOperation->SdkServiceMethod// TODO: how aboutSdkServiceOperationEnum->SdkEnumTypeEnumMember->SdkEnumValueTypeUnion->SdkUnionType// TODO: how about union as enumUnionVariant->SdkTypeScalar->SdkTypeInterface->SdkClientType
TCGC common models will contain the universal set of types in all the versions. Through apiVersions, emitter could know which version contains which type.
@addedexample@removedexample- ABA example
nameByVersionsproperty It could cover@renamedFromdecorator. This property is added to TCGC types according to different TypeSpec types just likeapiVersions. For all TCGC types, this property will show all the name in the versioning history.
@renamedFromexample- ABA example
optionalByVersionsproperty It could cover@madeOptionaldecorator. This property is added to TCGC types according to different TypeSpec types:
ModelProperty->SdkModelPropertyType
Model property or method parameter could change optional flag.
@madeOptionalexample- ABA example
typesByVersionsproperty It could cover@typeChangedFromand@returnTypeChangedFromdecorators. This property is added to TCGC types according to different TypeSpec types:
ModelProperty->SdkModelPropertyTypeOperation->SdkServiceMethod
Model proprety, method parameter or operation response could change types.
@typeChangedFromexample- ABA example