diff --git a/src/Refitter.Core/RefitInterfaceGenerator.cs b/src/Refitter.Core/RefitInterfaceGenerator.cs index 7e0365f1..df3540d4 100644 --- a/src/Refitter.Core/RefitInterfaceGenerator.cs +++ b/src/Refitter.Core/RefitInterfaceGenerator.cs @@ -1,6 +1,8 @@ using NSwag; using System; using System.Text; +using System.Linq; +using System.Collections.Generic; namespace Refitter.Core; @@ -42,9 +44,10 @@ private string GenerateInterfaceBody() { var operation = operations.Value; - var returnTypeParameter = operation.Responses.ContainsKey("200") - ? generator.GetTypeName(operation.Responses["200"].ActualResponse.Schema, true, null) - : null; + var returnTypeParameter = new[] { "200", "201", "203", "206" } + .Where(code => operation.Responses.ContainsKey(code)) + .Select(code => generator.GetTypeName(operation.Responses[code].ActualResponse.Schema, true, null)) + .FirstOrDefault(); var returnType = GetReturnType(returnTypeParameter); @@ -116,4 +119,4 @@ private string GenerateInterfaceDeclaration() var modifier = settings.TypeAccessibility.ToString().ToLowerInvariant(); return $"{Separator}{modifier} interface I{title.CapitalizeFirstCharacter()}"; } -} \ No newline at end of file +}