swagger-api / swagger-api/swagger-codegen

[Csharp]Can't set BasePath in Configuration because Timeout side effects forces ApiClient creation

Open
#10,399 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

version: export tool from https://app.swaggerhub.com/
Description
Originally I supposed I found such awesome convenient Tools which may help me quickly finish RESTful API Client, but I just followed with the README automatically generated by Codegen, I couldn't easily use the API without doing any change before generating the .dll. The example code also couldn't run properly, and I didn't know anywhere to find more documents but the README.
I knew I need to set the api server host url but no matter how I attempt to do it, it just throws the exception:
System.UriFormatException: Invalid URI: The format of the URI could not be determined.
I had to come back to find out why it couldn’t fetch the Baseurl I gave. After debugging I finally found the problem that "Setting Timeout has side effects (forces ApiClient creation).". But it almost have been specified as annotation... When new a Configuration Instance it will force ApiClient creation with the basepath = "/" before setting the Basepath property manually.
and I also find the related issues:
#10005
why not fixing this side effect, or just to specify in auto generated README? or there are any best practices? Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated C# Configuration and ApiClient behavior described in the issue, then reproduce the README/example setup that assigns BasePath and Timeout. Trace why setting Timeout creates ApiClient with the default base path, and verify that configuring the base URL no longer raises UriFormatException or that the required ordering is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.