From 454f4e7a4f0d6a115289070a49e7890c280f0449 Mon Sep 17 00:00:00 2001 From: FelixS90 Date: Fri, 17 Jan 2020 15:15:46 +0100 Subject: [PATCH] Allow custom json-based content type (#2633) --- src/NSwag.Core/OpenApiParameter.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NSwag.Core/OpenApiParameter.cs b/src/NSwag.Core/OpenApiParameter.cs index aa3a76d4ad..b4137c98e6 100644 --- a/src/NSwag.Core/OpenApiParameter.cs +++ b/src/NSwag.Core/OpenApiParameter.cs @@ -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; } } @@ -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; } } }