mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 19:02:24 +01:00
Don't return empty dictionary object for response headers in JSON mapping (#424)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
||||||
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
||||||
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
||||||
|
|||||||
@@ -124,11 +124,17 @@ namespace WireMock.Serialization
|
|||||||
mappingModel.Response.WebProxy = null;
|
mappingModel.Response.WebProxy = null;
|
||||||
mappingModel.Response.BodyDestination = response.ResponseMessage.BodyDestination;
|
mappingModel.Response.BodyDestination = response.ResponseMessage.BodyDestination;
|
||||||
mappingModel.Response.StatusCode = response.ResponseMessage.StatusCode;
|
mappingModel.Response.StatusCode = response.ResponseMessage.StatusCode;
|
||||||
mappingModel.Response.Headers = MapHeaders(response.ResponseMessage.Headers);
|
|
||||||
|
if (response.ResponseMessage.Headers != null && response.ResponseMessage.Headers.Count > 0)
|
||||||
|
{
|
||||||
|
mappingModel.Response.Headers = MapHeaders(response.ResponseMessage.Headers);
|
||||||
|
}
|
||||||
|
|
||||||
if (response.UseTransformer)
|
if (response.UseTransformer)
|
||||||
{
|
{
|
||||||
mappingModel.Response.UseTransformer = response.UseTransformer;
|
mappingModel.Response.UseTransformer = response.UseTransformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.UseTransformerForBodyAsFile)
|
if (response.UseTransformerForBodyAsFile)
|
||||||
{
|
{
|
||||||
mappingModel.Response.UseTransformerForBodyAsFile = response.UseTransformerForBodyAsFile;
|
mappingModel.Response.UseTransformerForBodyAsFile = response.UseTransformerForBodyAsFile;
|
||||||
@@ -197,12 +203,6 @@ namespace WireMock.Serialization
|
|||||||
private static IDictionary<string, object> MapHeaders(IDictionary<string, WireMockList<string>> dictionary)
|
private static IDictionary<string, object> MapHeaders(IDictionary<string, WireMockList<string>> dictionary)
|
||||||
{
|
{
|
||||||
var newDictionary = new Dictionary<string, object>();
|
var newDictionary = new Dictionary<string, object>();
|
||||||
|
|
||||||
if (dictionary == null || dictionary.Count == 0)
|
|
||||||
{
|
|
||||||
return newDictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var entry in dictionary)
|
foreach (var entry in dictionary)
|
||||||
{
|
{
|
||||||
object value = entry.Value.Count == 1 ? (object)entry.Value.ToString() : entry.Value;
|
object value = entry.Value.Count == 1 ? (object)entry.Value.ToString() : entry.Value;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
|
||||||
using WireMock.RequestBuilders;
|
using WireMock.RequestBuilders;
|
||||||
using WireMock.ResponseBuilders;
|
using WireMock.ResponseBuilders;
|
||||||
using WireMock.Serialization;
|
using WireMock.Serialization;
|
||||||
@@ -36,6 +35,7 @@ namespace WireMock.Net.Tests.Serialization
|
|||||||
model.Priority.Should().BeNull();
|
model.Priority.Should().BeNull();
|
||||||
model.Response.BodyAsJsonIndented.Should().BeNull();
|
model.Response.BodyAsJsonIndented.Should().BeNull();
|
||||||
model.Response.UseTransformer.Should().BeNull();
|
model.Response.UseTransformer.Should().BeNull();
|
||||||
|
model.Response.Headers.Should().BeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user