DI issue, Unable to resolve service for type 'System.String' while attempting to activate 'xxx.Client'."https://stackoverflow.com/
<ItemGroup>
<OpenApiReference Include="OpenAPIs\swagger.
<Options>/UseBaseUrl:false /GenerateClientInterfaces:
</OpenApiReference>
</ItemGroup>
https://learn.microsoft.com/
Install-Package Swashbuckle.AspNetCore -Version 6.2.3
1)Create WebAPI with swagger/OpenAPI
2)Create Web Application, add OpenAPI service reference
eg: URL: https://localhost:7179/ swagger/v1/swagger.json
3)From Web Application, create a client call the API
public List<WeatherForecast> Forecasts { get; set; }
public async Task OnGet()
{
swaggerClient swaggerClient;
string baseUrl = "https://localhost:7165/";
using (var client = new HttpClient())
{
swaggerClient = new swaggerClient(baseUrl, client);
Forecasts =(List < WeatherForecast >)await swaggerClient. GetWeatherForecastAsync();
}
}
1)Create WebAPI with swagger/OpenAPI
2)Create Web Application, add OpenAPI service reference
eg: URL: https://localhost:7179/
3)From Web Application, create a client call the API
public List<WeatherForecast> Forecasts { get; set; }
public async Task OnGet()
{
swaggerClient swaggerClient;
string baseUrl = "https://localhost:7165/";
using (var client = new HttpClient())
{
swaggerClient = new swaggerClient(baseUrl, client);
Forecasts =(List < WeatherForecast >)await swaggerClient.
}
}