dotnet / dotnet/aspnetcore

Exception when multiple OpenAPI services refrences is added in Visual Studio 2019 (swagger endpoints)

Open
#18,204 19 comments 5 reactions 0 assignees View on GitHub
affected-few area-mvc bug feature-openapi severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/content/problem/842525/exception-when-multiple-openapi-services-refrences.html)._

---
I try to use the service reference OpenAPI in Visual Studio 2019, to generate clients based on existing swagger endpoints. It works fine when one endpoint is added, but multiple endpoints in different namespaces does not work.
The reason is that the autogenerated APIException class is only generated in in the first "OpenApiReference".
I tried to set the option "generateExceptionClasses" but it didn't have any effect.
Also tried to give the exception different names with the option "exceptionClass", but the exception class was only created in the first client.

This is the code that fails:
```


https://api1/swagger/v1/swagger.json
{controller}Client
API1Client.cs


https://api2/swagger/v1/swagger.json
{controller}Client
API2Client.cs


```
It's possible to solve the problem with the following code, but I don't like to reference to API1 in API2:

```


https://api1/swagger/v1/swagger.json
{controller}Client
API1Client.cs


https://api2/swagger/v1/swagger.json
{controller}Client
API2Client.cs
/ExceptionClass:"API1. ApiException"


```
Any way to slove this?

---
### Original Comments

#### Visual Studio Feedback System on 12/5/2019, 00:01 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### Visual Studio Feedback System on 12/6/2019, 01:28 AM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2017#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

---
### Original Solutions
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.