Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Plan for adding flatten property tests

  • Explore repository structure and understand existing flatten-property tests
  • Add test case 1: Flatten property with unknown type
    • Add model with properties?: unknown field
    • Apply @Azure.ClientGenerator.Core.Legacy.flattenProperty decorator
    • Add PUT operation with scenario
    • Add mock API definition in mockapi.ts
  • Add test case 2: Flatten property with all read-only properties
    • Add SolutionProperties model with all @visibility(Lifecycle.Read) fields
    • Add Solution model with required and optional flattened properties
    • Add operation with body parameter
    • Add mock API definition in mockapi.ts
  • Build and validate the changes
    • Run build to compile TypeScript
    • Run validate-scenarios to ensure spec is valid
    • Run validate-mock-apis to ensure mock APIs are correct
  • Address review feedback
    • Remove unused @azure-tools/typespec-azure-core import and using global.Azure.Core
  • Request code review

Summary

Successfully added two new test cases and addressed review feedback to remove unnecessary imports.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Spector] Add more tests for flatten property</issue_title>
<issue_description>Add two tests under packages/azure-http-specs/specs/azure/client-generator-core/flatten-property:

  1. Flatten property case for an non-model type like unknown, typespec like this:
model XXX {
  #suppress "@azure-tools/typespec-azure-core/no-unknown" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
  properties?: unknown;
}

@@Azure.ClientGenerator.Core.Legacy.flattenProperty(XXX.properties);
  1. Flatten property case for all readOnly, typespec like this:
model SolutionProperties {
  @visibility(Lifecycle.Read)
  solutionId?: string;
  @visibility(Lifecycle.Read)
  title?: string;
  @visibility(Lifecycle.Read)
  content?: string;
}
model Solution{
  @Azure.ClientGenerator.Core.Legacy.flattenProperty
  properties: SolutionProperties;
  @Azure.ClientGenerator.Core.Legacy.flattenProperty
  propertiesOptional?: SolutionProperties;
}
op test(@body body:Solution):void;

/cc @MaryGao </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ties

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for flatten property functionality Add flatten property tests for unknown type and read-only properties Jan 8, 2026
Copilot AI requested a review from v-jiaodi January 8, 2026 02:39
using Http;
using global.Azure.ClientGenerator.Core;
using Spector;
using global.Azure.Core;
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove import "@azure-tools/typespec-azure-core" and using global.Azure.Core as it is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 260bfdf. Removed the unused import and using statement - the Lifecycle enum is available without explicitly importing Azure.Core.

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copilot AI requested a review from v-jiaodi January 22, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spector] Add more tests for flatten property

2 participants