OpenAPITools / OpenAPITools/openapi-generator
[csharp][generichost] Concatenation can produce invalid url
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
P2: Path concatenation can produce a double-slash when BaseAddress.AbsolutePath ends with '/', resulting in a different URL path (e.g., /api//widgets/{id}) that may not match server routes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Api/DefaultApi.cs, line 236:
<comment>Path concatenation can produce a double-slash when BaseAddress.AbsolutePath ends with '/', resulting in a different URL path (e.g., /api//widgets/{id}) that may not match server routes.</comment>
<file context>
@@ -0,0 +1,383 @@
+ uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme;
+ uriBuilderLocalVar.Path = HttpClient.BaseAddress.AbsolutePath == "/"
+ ? "/widgets/{id}"
+ : string.Concat(HttpClient.BaseAddress.AbsolutePath, "/widgets/{id}");
+ uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Bid%7D", Uri.EscapeDataString(id.ToString()));
+
</file context>
Originally posted by @cubic-dev-ai[bot] in https://github.com/OpenAPITools/openapi-generator/pull/23260#discussion_r2937210193
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Api/DefaultApi.cs around line 236 and reproduce the request with BaseAddress.AbsolutePath ending in '/'. Confirm the resulting URL path, then update the relevant path-concatenation behavior so the generated URL does not contain an unintended double slash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100