Skip to content

Conversation

@v-jiaodi
Copy link
Member

@v-jiaodi v-jiaodi commented Nov 11, 2025

fixes #3588

1.When a discriminated union type has a @@clientNamespace decorator, the union serializer should call the correctly-scoped serializer function names that match the actual function definitions. the actual generated union did not include the corresponding prefix.
expected code:

export type AzureSearchDocumentsIndexesScoringFunctionUnion

return azureSearchDocumentsKnowledgeBaseKnowledgeRetrievalMinimalReasoningEffortSerializer(  
        item as azureSearchDocumentsKnowledgeRetrievalMinimalReasoningEffort,
      );

Actual generated code:

export function azureSearchDocumentsKnowledgeBaseKnowledgeRetrievalReasoningEffortUnionSerializer(
  item: KnowledgeRetrievalReasoningEffortUnion,
): any {
  switch (item.kind) {
    case "minimal":
      return knowledgeRetrievalMinimalReasoningEffortSerializer(  // ❌ Function doesn't exist
        item as KnowledgeRetrievalMinimalReasoningEffort,
      );
    default:
      return azureSearchDocumentsKnowledgeBaseKnowledgeRetrievalReasoningEffortSerializer(item);
  }
}
export type ScoringFunctionUnion
export function azureSearchDocumentsIndexesScoringFunctionUnionArraySerializer(
  result: Array<AzureSearchDocumentsIndexesScoringFunctionUnion>, // ❌ Union doesn't exist
): any[] {
  return result.map((item) => {
    return azureSearchDocumentsIndexesScoringFunctionUnionSerializer(item);
  });
}

2.Using @@clientName decorator affected the inheritance of properties with the same name, causing duplication.

Actual generated code:

export function customNormalizerSerializer(item: CustomNormalizer): any {
  return {
    "@odata.type": item["odataType"],
    name: item["name"],
    tokenFilters: !item["tokenFilters"]
      ? item["tokenFilters"]
      : item["tokenFilters"].map((p: any) => {
          return p;
        }),
    charFilters: !item["charFilters"]
      ? item["charFilters"]
      : item["charFilters"].map((p: any) => {
          return p;
        }),
    "@odata.type": item["odataType"],// ❌ duplicate
  };
}

#suppress "@azure-tools/typespec-azure-core/casing-style" "Maintain compatibility with existing models."
`@odata.type`: "#Microsoft.Azure.Search.CustomNormalizer";
}
@@clientName(LexicalNormalizer.`@odata.type`, "odataType");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using @@clientName affected the inheritance of properties with the same name, causing duplication.

needOptions?: boolean;
withRawContent?: boolean;
needAzureCore?: boolean;
needTCGC?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support needTCGC config for ut

@v-jiaodi v-jiaodi changed the title [Test] Azure search smoke Fix inconsistent Serializer Function Names in Discriminated Unions Nov 12, 2025
@qiaozha qiaozha added the P1 priority 1 label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 priority 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modular: Inconsistent Serializer Function Names in Discriminated Unions

3 participants