Open alalloo opened 4 years ago
I'd say you should have only one of them and merge the descriptions.
Absolutely, and that was the fix I did - this issue is only a suggestion to make the cause of the problem be understandable from the returned error message since it took me a really long time to figure out what the problem was, from diving into nswag source code.
Would also appreciate better error message. Took me also some time before I noticed to read the call stack far enough to notice this was about XML docs. Was searching for actual code changes that could have some duplication like Attributes. Anyways the information was hiding in plain sight in that call stack. Also did not find this issue with google using the error message.
Executing file 'nswag.json' with variables ''... System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable
1 source, Func
2 predicate, Boolean& found) at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func
2 predicate) at NSwag.Generation.Processors.OperationResponseProcessorBase.GetResponseXmlDocsElement(MethodInfo methodInfo, String responseCode) in /_/src/NSwag.Generation/Processors/OperationResponseProcessorBase.cs:line 97
Created a PR #4388. Did not test it yet though as I could not get the nswag repo's build to work.
I've also run into this problem today.
I agree that a more descriptive error message/console output from NSwag would be really useful in tracking down which endpoint it was choking on.
Since the PR #4388 has been merged, could this issue be closed?
A controller might have several reasons to return a bad request status and in our project had them declared like below which is handled OK by Swagger. But switching to NSwag was problematic since it caused an exception and it was really hard knowing what NSwag was unhappy about. I had to clone nswag repo and debug it to find what was the problem (which then could trivially be corrected).
A proper error message to user would have saved a couple of hours.
The exception