Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Adds two test cases to packages/azure-http-specs/specs/azure/client-generator-core/flatten-property to validate flatten property behavior in edge cases.

Test 1: Flatten property with unknown type

  • Model with properties?: unknown field decorated with @flattenProperty
  • Validates flattening behavior when property type is non-model
model FlattenUnknownModel {
  name: string;
  
  #suppress "@azure-tools/typespec-azure-core/no-unknown" "For testing purposes"
  #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "Testing backcompat"
  @Azure.ClientGenerator.Core.Legacy.flattenProperty
  properties?: unknown;
}

Test 2: Flatten property with all read-only properties

  • Model where all flattened properties use @visibility(Lifecycle.Read)
  • Tests both required and optional flatten property fields
model SolutionProperties {
  @visibility(Lifecycle.Read)
  solutionId?: string;
  @visibility(Lifecycle.Read)
  title?: string;
  @visibility(Lifecycle.Read)
  content?: string;
}

model Solution {
  name: string;
  
  @Azure.ClientGenerator.Core.Legacy.flattenProperty
  properties: SolutionProperties;
  
  @Azure.ClientGenerator.Core.Legacy.flattenProperty
  propertiesOptional?: SolutionProperties;
}

Both tests include corresponding operations and mock API definitions following existing spec patterns.

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
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