Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 165 forks source link

DPG: ContinuationToken and maxPage size should be surfaced through Pageable<T> #2980

Open lirenhe opened 1 year ago

lirenhe commented 1 year ago

Current generated code:

public virtual Pageable(string testId, string continuationToken = null, RequestContext context = null);

public virtual Pageable (string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, string continuationToken = null, int? maxpagesize = null, RequestContext context = null);

Based on the comments for archboard: https://apiview.dev/Assemblies/Review/4200a804f382479bb4d2bb4a3323b8c7

We need to config it to be part of Pageable similarly in second one maxpagesize is part of method, we also wanted it to part of Pageable.

Source Swagger: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/loadtestservice/data-plane/Microsoft.LoadTestService/stable/2022-11-01/loadtestservice.json

chunyu3 commented 1 year ago

It is not codegen issue. Codgen generate the correct code according to the swagger definition. Need to update the swagger to surface those two paramters.

lirenhe commented 1 year ago

@chunyu3, do you know how the updated swagger would look like?

tg-msft commented 10 months ago

This is an issue with the code generation.

maxpagesize is a standard Azure query parameter as described at https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#query-options. This should not be surfaced as a method parameter, but rather via Pageable<T>'s GetPages(pageSizeHint: 30) method at https://learn.microsoft.com/en-us/dotnet/api/azure.pageable-1.aspages?view=azure-dotnet.