Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(csharp): Fix inline path parameters with pagination endpoints #6290

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion fern/pages/changelogs/csharp-sdk/2025-03-03.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
- Use `base-api-exception-class-name` if configured,
- otherwise, fall back to `exported-client-class-name` if configured, with `ApiException` suffix,
- otherwise, fall back to `client-class-name` if configured, with `ApiException` suffix,
- otherwise, fall back to the computed client name, with `ApiException` suffix.
- otherwise, fall back to the computed client name, with `ApiException` suffix.

## 1.12.0-rc9
**`(fix):`** Fix inline path parameters with pagination endpoints.
54 changes: 36 additions & 18 deletions generators/csharp/sdk/src/endpoint/AbstractEndpointGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,11 @@ export abstract class AbstractEndpointGenerator {
serviceId: ServiceId;
endpoint: HttpEndpoint;
}): EndpointSignatureInfo {
const request = getEndpointRequest({ context: this.context, endpoint, serviceId });
const requestParameter =
request != null
? csharp.parameter({ type: request.getParameterType(), name: request.getParameterName() })
: undefined;
const { pathParameters, pathParameterReferences } = this.getAllPathParameters({
return this.getEndpointSignatureInfoFor({
serviceId,
endpoint,
requestParameter
endpointType: "unpaged"
});
return {
baseParameters: [...pathParameters, requestParameter].filter((p): p is csharp.Parameter => p != null),
pathParameters,
pathParameterReferences,
request,
requestParameter,
returnType: getEndpointReturnType({ context: this.context, endpoint })
};
}

protected getPagerEndpointSignatureInfo({
Expand All @@ -66,19 +54,49 @@ export abstract class AbstractEndpointGenerator {
serviceId: ServiceId;
endpoint: HttpEndpoint;
}): EndpointSignatureInfo {
const { pathParameters, pathParameterReferences } = this.getAllPathParameters({ endpoint });
return this.getEndpointSignatureInfoFor({
serviceId,
endpoint,
endpointType: "paged"
});
}

protected getEndpointSignatureInfoFor({
serviceId,
endpoint,
endpointType
}: {
serviceId: ServiceId;
endpoint: HttpEndpoint;
endpointType: "unpaged" | "paged";
}): EndpointSignatureInfo {
const request = getEndpointRequest({ context: this.context, endpoint, serviceId });
const requestParameter =
request != null
? csharp.parameter({ type: request.getParameterType(), name: request.getParameterName() })
: undefined;
const { pathParameters, pathParameterReferences } = this.getAllPathParameters({
endpoint,
requestParameter
});
let returnType: csharp.Type | undefined;
switch (endpointType) {
case "unpaged":
returnType = getEndpointReturnType({ context: this.context, endpoint });
break;
case "paged":
returnType = this.getPagerReturnType(endpoint);
break;
default:
assertNever(endpointType);
}
return {
baseParameters: [...pathParameters, requestParameter].filter((p): p is csharp.Parameter => p != null),
pathParameters,
pathParameterReferences,
request,
requestParameter,
returnType: this.getPagerReturnType(endpoint)
returnType
};
}

Expand Down Expand Up @@ -129,7 +147,7 @@ export abstract class AbstractEndpointGenerator {
requestParameter
}: {
endpoint: HttpEndpoint;
requestParameter?: csharp.Parameter;
requestParameter: csharp.Parameter | undefined;
}): Pick<EndpointSignatureInfo, "pathParameters" | "pathParameterReferences"> {
const pathParameters: csharp.Parameter[] = [];
const pathParameterReferences: Record<string, string> = {};
Expand Down
7 changes: 7 additions & 0 deletions generators/csharp/sdk/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
# Set `enable-forward-compatible-enums` to `false` in the configuration to generate the old enums.
# irVersion: 53

- version: 1.12.0-rc9
createdAt: "2025-03-03"
irVersion: 56
changelogEntry:
- type: fix
summary: Fix inline path parameters with pagination endpoints.

- version: 1.12.0-rc8
createdAt: "2025-03-03"
irVersion: 56
Expand Down
Loading