Skip to content

Pageable<T> instead of IList should be generated when the response is an array #54544

@RodgeFu

Description

@RodgeFu

With following typespec:

  /**
   * List private endpoint connection properties
   */
  @action("privateEndpointConnections")
  @get
  listPrivateEndpointConnections is ArmProviderActionSync<
    void,
    ArmResponse<PrivateEndpointConnectionsList>,
    {},
    {
      /** Name of the provisioning service to retrieve. */
      @path @segment("provisioningServices") resourceName: string;
    },
    ErrorDetails
  >;
  /**
   * Represents a list of private endpoint connections.
   */
  #suppress "@azure-tools/typespec-azure-resource-manager/no-empty-model" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
  model PrivateEndpointConnectionsList is PrivateEndpointConnection[];

IList<> is generated instead of Pageable<> like below:

        public virtual async Task<Response<IList<DeviceProvisioningServicesPrivateEndpointConnectionData>>> GetPrivateEndpointConnectionsAsync(string resourceName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName));

            using DiagnosticScope scope = PrivateEndpointConnectionsClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesResourceGroupResource.GetPrivateEndpointConnections");
            scope.Start();
            try
            {
                RequestContext context = new RequestContext
                {
                    CancellationToken = cancellationToken
                };
                HttpMessage message = PrivateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionsRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, context);
                Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
                Response<IList<DeviceProvisioningServicesPrivateEndpointConnectionData>> response = Response.FromValue(IList<DeviceProvisioningServicesPrivateEndpointConnectionData>.FromResponse(result), result);
                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return response;
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public static Response<IList<DeviceProvisioningServicesPrivateEndpointConnectionData>> GetPrivateEndpointConnections(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource));

            return GetMockableDeviceProvisioningServicesResourceGroupResource(resourceGroupResource).GetPrivateEndpointConnections(resourceName, cancellationToken);
        }

It's expected to generate as pageable operation with only one page(Pageable implements IEnumerable).

As a full repro, you can generate against service 'deviceprovisioningservices', build and check method public static Response<IList<DeviceProvisioningServicesPrivateEndpointConnectionData>> GetPrivateEndpointConnections(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default) or public virtual Response<IList<DeviceProvisioningServicesPrivateEndpointConnectionData>> GetPrivateEndpointConnections(string resourceName, CancellationToken cancellationToken = default)
github link for your convenience:
https://github.com/mzhongl524/azure-sdk-for-net/blob/1e0c32b376fed108556b716a1e30930541898861/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesResourceGroupResource.cs#L283
https://github.com/mzhongl524/azure-sdk-for-net/blob/1e0c32b376fed108556b716a1e30930541898861/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/DeviceProvisioningServicesExtensions.cs#L234

Metadata

Metadata

Assignees

Labels

CodeGenIssues that relate to code generationMgmtThis issue is related to a management package.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions