Skip to content

Commit

Permalink
(fix, csharp): sdk respects service level path and path parameters (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Jun 21, 2024
1 parent 3671180 commit 1ae3090
Show file tree
Hide file tree
Showing 156 changed files with 931 additions and 194 deletions.
4 changes: 3 additions & 1 deletion generators/csharp/codegen/src/asIs/RawClient.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public class ApiResponse

private string BuildUrl(string path, Dictionary<string, object> query)
{
var url = $"{_clientOptions.BaseUrl}{path}";
uri1 = _clientOptions.BaseUrl.TrimEnd('/');
uri2 = path.TrimStart('/');
var url = $"{uri1}/{uri2}";
if (query.Count > 0)
{
url += "?";
Expand Down
4 changes: 4 additions & 0 deletions generators/csharp/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.29 - 2024-06-20]

- Fix: The generated SDK now respects service base paths. Previously they were omitted.

## [0.0.28 - 2024-06-19]

- Improvement: Query parameter and header parameters with optional datetimes are
Expand Down
2 changes: 1 addition & 1 deletion generators/csharp/sdk/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.28
0.0.29
3 changes: 2 additions & 1 deletion generators/csharp/sdk/src/endpoint/EndpointGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ export class EndpointGenerator {
pathParameterReferences: Record<string, string>;
} {
const parameters: csharp.Parameter[] = [];
const service = this.context.getHttpServiceOrThrow(serviceId);
const pathParameterReferences: Record<string, string> = {};
for (const pathParam of endpoint.pathParameters) {
for (const pathParam of [...service.pathParameters, ...endpoint.pathParameters]) {
const parameterName = pathParam.name.camelCase.safeName;
pathParameterReferences[pathParam.name.originalName] = parameterName;
parameters.push(
Expand Down
11 changes: 7 additions & 4 deletions generators/csharp/sdk/src/endpoint/RawClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export class RawClient {
{
name: "Path",
assignment: csharp.codeblock(
`${this.getPathString({ endpoint, pathParameterReferences: pathParameterReferences ?? {} })}`
`${this.getPathString({
endpoint,
pathParameterReferences: pathParameterReferences ?? {}
})}`
)
}
];
Expand Down Expand Up @@ -114,14 +117,14 @@ export class RawClient {
endpoint: HttpEndpoint;
pathParameterReferences: Record<string, string>;
}): string {
let path = endpoint.path.head;
let path = endpoint.fullPath.head;
let pathParametersPresent = false;
for (const part of endpoint.path.parts) {
for (const part of endpoint.fullPath.parts) {
pathParametersPresent = true;
const reference = pathParameterReferences[part.pathParameter];
if (reference == null) {
throw new Error(
`Failed to find request parameter for the endpointt ${endpoint.id} with path parameter ${part.pathParameter}`
`Failed to find request parameter for the endpointt${endpoint.id} with path parameter ${part.pathParameter}`
);
}
path += `{${reference}}${part.tail}`;
Expand Down
4 changes: 3 additions & 1 deletion seed/csharp-sdk/alias/src/SeedAlias/Core/RawClient.cs

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

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

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

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

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

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

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

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

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

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

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

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

4 changes: 3 additions & 1 deletion seed/csharp-sdk/bytes/src/SeedBytes/Core/RawClient.cs

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

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

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

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

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

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

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

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

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

4 changes: 3 additions & 1 deletion seed/csharp-sdk/enum/src/SeedEnum/Core/RawClient.cs

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

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

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

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

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

Loading

0 comments on commit 1ae3090

Please sign in to comment.