Skip to content

Commit

Permalink
clone request before paginating
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Nov 19, 2024
1 parent 59dbb9b commit baee9f0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
15 changes: 9 additions & 6 deletions generators/csharp/sdk/src/endpoint/http/HttpEndpointGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class HttpEndpointGenerator extends AbstractEndpointGenerator {
this.generateHttpMethod({ serviceId, endpoint, rawClientReference, rawClient })
];
if (this.hasPagination(endpoint)) {
methods.push(this.generateHttpPagerMethod({ serviceId, endpoint, rawClientReference, rawClient }));
methods.push(this.generateHttpPagerMethod({ serviceId, endpoint }));
}
return methods;
}
Expand Down Expand Up @@ -315,14 +315,10 @@ export class HttpEndpointGenerator extends AbstractEndpointGenerator {

public generateHttpPagerMethod({
serviceId,
endpoint,
rawClientReference,
rawClient
endpoint
}: {
serviceId: ServiceId;
endpoint: HttpEndpoint;
rawClientReference: string;
rawClient: RawClient;
}): csharp.Method {
this.assertHasPagination(endpoint);
const endpointSignatureInfo = this.getEndpointSignatureInfo({ serviceId, endpoint });
Expand Down Expand Up @@ -352,6 +348,13 @@ export class HttpEndpointGenerator extends AbstractEndpointGenerator {
throw new Error("Internal error; a response type is required for pagination endpoints");
}

writer.writeLine("if (request is not null)");
writer.writeLine("{");
writer.indent();
writer.writeLine("request = request with { };");
writer.dedent();
writer.writeLine("}");

switch (endpoint.pagination.type) {
case "offset":
this.generateOffsetMethodBody({
Expand Down
40 changes: 40 additions & 0 deletions seed/csharp-sdk/pagination/src/SeedPagination/Users/UsersClient.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit baee9f0

Please sign in to comment.