Skip to content

Commit

Permalink
Allow custom json-based content type (RicoSuter#2633)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixS90 authored and RicoSuter committed Jan 17, 2020
1 parent 4b4dd89 commit 454f4e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/NSwag.Core/OpenApiParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public bool IsXmlBodyParameter

return consumes?.Any() == true &&
consumes.Any(p => p.Contains("application/xml")) &&
consumes.Any(p => p.Contains("application/json")) == false;
consumes.Any(p => p.StartsWith("application/") && p.EndsWith("json")) == false;
}
}

Expand All @@ -243,14 +243,14 @@ public bool IsBinaryBodyParameter
var consumes = parent.ActualConsumes;
return consumes?.Any() == true &&
consumes.Any(p => p.Contains("*/*")) == false && // supports json
consumes.Any(p => p.Contains("application/json")) == false;
consumes.Any(p => p.StartsWith("application/") && p.EndsWith("json")) == false;
}
else
{
var consumes = parent?.RequestBody?.Content;
return consumes?.Any() == true &&
consumes.Any(p => p.Key.Contains("*/*") && !p.Value.Schema.IsBinary) == false && // supports json
consumes.Any(p => p.Key.Contains("application/json") && p.Value.Schema?.IsBinary != true) == false;
consumes.Any(p => p.Key.StartsWith("application/") && p.Key.EndsWith("json") && p.Value.Schema?.IsBinary != true) == false;
}
}
}
Expand Down

0 comments on commit 454f4e7

Please sign in to comment.