I would like to add an OpenAPI service reference to an existing project. Within the Connected Services view, the next values are used:
Afterwards I click on Finish, build the project and add the PetStoreApiClient.cs to the project.
Finally I try to build the solution (again) while using the PetStoreApiClient. Visual Studio displays several compile errors, e.g.:
Several items are duplicated, even the baseUrl is generated multiple times:
Ambiguity between 'PetStoreApiClient.BaseUrl' and 'PetStoreApiClient.BaseUrl' ConsoleApp C:\..\ConsoleApp\ConsoleApp\obj\openapi1Client.cs
The csproj file contains the next settings, as visualized in the first screenshot:
<ItemGroup>
<OpenApiReference Include="OpenAPIs\openapi.json" CodeGenerator="NSwagCSharp" ClassName="PetStoreApiClient" OutputPath="PetStoreApiClient.cs">
<SourceUri>https://petstore3.swagger.io/api/v3/openapi.json</SourceUri>
</OpenApiReference>
Should I use different settings? Add a setting within the csproj? A similar issue is described on GitHub, but the provided solutions don't work.