Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b4f5cd7
minor: added long path support to prerequisite
radhgupta Oct 22, 2025
ccef568
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Oct 23, 2025
3486047
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Oct 31, 2025
25e823a
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Nov 4, 2025
7958158
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Nov 13, 2025
5227fce
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Nov 13, 2025
175f199
Merge remote-tracking branch 'upstream/main'
radhgupta Nov 14, 2025
b39a7f4
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Dec 1, 2025
699978e
Merge branch 'main' of https://github.com/microsoft/typespec
radhgupta Dec 15, 2025
d0909f3
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 6, 2026
17ae707
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 7, 2026
339819f
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 13, 2026
9cb6c4c
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 21, 2026
23227a6
merge
radhgupta Jan 22, 2026
11bd3b3
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 28, 2026
f607b58
Merge remote-tracking branch 'upstream/main'
radhgupta Jan 28, 2026
1349fcb
rename top to maxCount
radhgupta Jan 29, 2026
e0f3d76
Merge branch 'main' into topToMaxcount
radhgupta Jan 29, 2026
396f51c
rename top to maxCount
radhgupta Jan 29, 2026
052df40
Merge branch 'topToMaxcount' of https://github.com/radhgupta/typespec…
radhgupta Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class RestClientProvider : TypeProvider
private const string RepeatabilityRequestIdHeader = "Repeatability-Request-ID";
private const string RepeatabilityFirstSentHeader = "Repeatability-First-Sent";
private const string MaxPageSizeParameterName = "maxpagesize";
private const string TopParameterName = "top";
private const string MaxCountParameterName = "maxCount";
private const string ApiVersionParameterName = "api-version";

private static readonly Dictionary<string, ParameterProvider> _knownSpecialHeaderParams = new(StringComparer.OrdinalIgnoreCase)
Expand Down Expand Up @@ -955,6 +957,13 @@ internal static List<ParameterProvider> GetMethodParameters(
continue;
}

// For paging operations, rename "top" parameter to "maxCount"
if (serviceMethod is InputPagingServiceMethod &&
string.Equals(inputParam.Name, TopParameterName, StringComparison.OrdinalIgnoreCase))
{
inputParam.Update(name: MaxCountParameterName);
}

ParameterProvider? parameter = ScmCodeModelGenerator.Instance.TypeFactory.CreateParameter(inputParam)?.ToPublicInputParameter();
if (parameter is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ public void NoNextLinkOrContinuationTokenAsync()
Assert.AreEqual(Helpers.GetExpectedFromFile(), file.Content);
}

[Test]
public void TopParameterRenamedToMaxCountInPagingOperation()
{
var topParameter = InputFactory.QueryParameter("top", InputPrimitiveType.Int32);
var pagingMetadata = InputFactory.PagingMetadata(["items"], null, null);
var responseModel = InputFactory.Model("Response", properties: [
InputFactory.Property("items", InputFactory.Array(InputPrimitiveType.String))
]);
var response = InputFactory.OperationResponse([200], responseModel);
var operation = InputFactory.Operation("getItems", parameters: [topParameter], responses: [response]);
var pagingMethod = InputFactory.PagingServiceMethod("getItems", operation, pagingMetadata: pagingMetadata);
var client = InputFactory.Client("testClient", methods: [pagingMethod]);

MockHelpers.LoadMockGenerator(inputModels: () => [responseModel], clients: () => [client]);

var restClientProviders = ScmCodeModelGenerator.Instance.OutputLibrary.TypeProviders
.OfType<RestClientProvider>().ToList();

Assert.IsTrue(restClientProviders.Count > 0, "RestClientProvider should be generated");

var parameterNames = restClientProviders
.SelectMany(p => p.Methods)
.SelectMany(m => m.Signature.Parameters)
.Select(param => param.Name)
.ToList();

Assert.Contains("maxCount", parameterNames, "Should contain 'maxCount' parameter");
Assert.IsFalse(parameterNames.Contains("top"), "Should not contain 'top' parameter after renaming");
}

[Test]
public void NoNextLinkOrContinuationTokenOfT()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ protected InputParameter(
/// Update the instance with given parameters.
/// </summary>
/// <param name="scope">The scope of the <see cref="InputParameter"/></param>
public void Update(InputParameterScope scope)
/// <param name="name">The name of the <see cref="InputParameter"/></param>
public void Update(InputParameterScope? scope = null, string? name = null)
{
Scope = scope;
if (scope.HasValue)
{
Scope = scope.Value;
}
if (name != null)
{
Name = name;
}
}

public static InputParameterScope ParseScope(InputType type, string name, string? scope)
Expand Down