swagger-api / swagger-api/swagger-codegen
Setting Configuration.DefaultApiClient is ignored
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
The code below, from Configuration.cs is causing problems.
public static ApiClient DefaultApiClient = new ApiClient();
because ApiClient is defined like:
public ApiClient(String basePath="/")
When I want to set my valid url, static DefaultApiClient initialise ApiClient with "/" and complains about it.
var baseUrl = "my-valid-url";
Configuration.DefaultApiClient = new ApiClient(baseUrl);
Unhandled exception. System.TypeInitializationException: The type initializer for 'IO.Swagger.Client.Configuration' threw an exception.
---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
Possible fix, define it like this in Configuration.cs:
public static ApiClient DefaultApiClient;
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 with Configuration.cs and inspect how DefaultApiClient is initialized alongside the ApiClient constructor in the issue. Confirm that assigning a valid ApiClient no longer triggers a type-initialization failure caused by the default "/" base path, then verify the generated client initializes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100