Skip to content

Commit

Permalink
fix(csharp): Fix inline path parameters with pagination endpoints (#6290
Browse files Browse the repository at this point in the history
)

Fix inline path parameters with pagination endpoints.
  • Loading branch information
Swimburger authored Mar 3, 2025
1 parent 26355fd commit d122a13
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
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

0 comments on commit d122a13

Please sign in to comment.