Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ export function dataProductVersionDeserializer(item: any): DataProductVersion {
/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */
export interface ProxyResource extends Resource {}

export function proxyResourceSerializer(item: ProxyResource): any {
return item;
export function proxyResourceSerializer(_item: ProxyResource): any {
return {};
}

export function proxyResourceDeserializer(item: any): ProxyResource {
Expand All @@ -341,8 +341,8 @@ export interface Resource {
readonly systemData?: SystemData;
}

export function resourceSerializer(item: Resource): any {
return item;
export function resourceSerializer(_item: Resource): any {
return {};
}

export function resourceDeserializer(item: any): Resource {
Expand Down Expand Up @@ -572,8 +572,8 @@ export function dataTypeUpdatePropertiesSerializer(item: DataTypeUpdatePropertie
/** model interface _DeleteDataRequest */
export interface _DeleteDataRequest {}

export function _deleteDataRequestSerializer(item: _DeleteDataRequest): any {
return item;
export function _deleteDataRequestSerializer(_item: _DeleteDataRequest): any {
return {};
}

/** The details for container sas creation. */
Expand Down Expand Up @@ -1139,8 +1139,8 @@ export interface UserAssignedIdentity {
readonly clientId?: string;
}

export function userAssignedIdentitySerializer(item: UserAssignedIdentity): any {
return item;
export function userAssignedIdentitySerializer(_item: UserAssignedIdentity): any {
return {};
}

export function userAssignedIdentityDeserializer(item: any): UserAssignedIdentity {
Expand Down Expand Up @@ -1369,8 +1369,8 @@ export function roleAssignmentDetailDeserializer(item: any): RoleAssignmentDetai
/** model interface _ListRolesAssignmentsRequest */
export interface _ListRolesAssignmentsRequest {}

export function _listRolesAssignmentsRequestSerializer(item: _ListRolesAssignmentsRequest): any {
return item;
export function _listRolesAssignmentsRequestSerializer(_item: _ListRolesAssignmentsRequest): any {
return {};
}

/** list role assignments. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export interface VirtualMachineProperties {
readonly provisioningState?: ResourceProvisioningState;
}

export function virtualMachinePropertiesSerializer(item: VirtualMachineProperties): any {
return item;
export function virtualMachinePropertiesSerializer(_item: VirtualMachineProperties): any {
return {};
}

export function virtualMachinePropertiesDeserializer(item: any): VirtualMachineProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export interface DiskProperties {
readonly provisioningState?: ResourceProvisioningState;
}

export function diskPropertiesSerializer(item: DiskProperties): any {
return item;
export function diskPropertiesSerializer(_item: DiskProperties): any {
return {};
}

export function diskPropertiesDeserializer(item: any): DiskProperties {
Expand Down Expand Up @@ -153,8 +153,8 @@ export interface DiskAccessProperties {
readonly timeCreated?: Date;
}

export function diskAccessPropertiesSerializer(item: DiskAccessProperties): any {
return item;
export function diskAccessPropertiesSerializer(_item: DiskAccessProperties): any {
return {};
}

export function diskAccessPropertiesDeserializer(item: any): DiskAccessProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export interface Resource {
readonly systemData?: SystemData;
}

export function resourceSerializer(item: Resource): any {
return item;
export function resourceSerializer(_item: Resource): any {
return {};
}

export function resourceDeserializer(item: any): Resource {
Expand Down
36 changes: 34 additions & 2 deletions packages/typespec-ts/src/modular/emitModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,31 @@ function buildModelInterface(
type: SdkModelType
): InterfaceDeclarationStructure {
const flattenPropertySet = new Set<SdkModelPropertyType>();
// For non-input models (output-only, exception, etc.), filter out metadata
// properties (@header, @query, @path) since they are deserialized separately.
// For input models, keep metadata properties — users need to pass them.
const hasInputUsage = (type.usage & UsageFlags.Input) === UsageFlags.Input;
const isArmResource = isArmResourceModel(type);
const interfaceStructure = {
kind: StructureKind.Interface,
name: normalizeModelName(context, type, NameType.Interface, true),
isExported: true,
properties: type.properties
.filter((p) => !isMetadata(context.program, p.__raw!))
.filter((p) => {
if (!hasInputUsage && p.__raw && isMetadata(context.program, p.__raw)) {
return false;
}
// Skip the "name" metadata property on ARM resource models.
// ARM resource "name" is a @path property inherited from the base Resource type
// and is handled by the ARM infrastructure, not set by the user directly.
if (
isArmResource &&
p.name === "name" &&
p.__raw &&
isMetadata(context.program, p.__raw)
) {
return false;
}
// filter out the flatten property to be processed later
if (p.flatten && p.type.kind === "model") {
flattenPropertySet.add(p);
Expand All @@ -757,7 +775,7 @@ function buildModelInterface(
context,
flatten.type,
getAllAncestors(flatten.type)
).filter((p) => !isMetadata(context.program, p.__raw!));
);
interfaceStructure.properties!.push(
...allProperties.map((p) => {
// when the flattened property is optional, all its child properties should be optional too
Expand Down Expand Up @@ -932,6 +950,20 @@ export function normalizeModelName(
return `${internalModelPrefix}${normalizeName(namespacePrefix + type.name, nameType, true)}${unionSuffix}`;
}

/**
* Checks if a model descends from the ARM common-types Resource base type
* (TrackedResource, ProxyResource, etc.) by walking the ancestor chain.
*/
function isArmResourceModel(type: SdkModelType): boolean {
Comment thread
qiaozha marked this conversation as resolved.
const ancestors = getAllAncestors(type);
return ancestors.some(
(ancestor) =>
ancestor.kind === "model" &&
ancestor.crossLanguageDefinitionId ===
"Azure.ResourceManager.CommonTypes.Resource"
);
}

function buildModelPolymorphicType(context: SdkContext, type: SdkModelType) {
// Only include direct subtypes in this union
const directSubtypes = getDirectSubtypes(type);
Expand Down
Loading
Loading