diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/Interaction.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/Interaction.cs
index f9cd9855..484fba69 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/Interaction.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/Interaction.cs
@@ -5,11 +5,11 @@ namespace WireMock.Pact.Models.V2;
public class Interaction
{
- public string? Description { get; set; }
+ public required string Description { get; set; }
public string? ProviderState { get; set; }
- public PactRequest Request { get; set; } = new();
+ public required PactRequest Request { get; set; }
- public PactResponse Response { get; set; } = new();
+ public required PactResponse Response { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/MatchingRule.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/MatchingRule.cs
index ada09a34..6fcefea1 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/MatchingRule.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/MatchingRule.cs
@@ -8,20 +8,20 @@ public class MatchingRule
///
/// type or regex
///
- public string Match { get; set; } = "type";
+ public required string Match { get; set; }
///
/// Used for Match = "type"
///
- public string Min { get; set; }
+ public string? Min { get; set; }
///
/// Used for Match = "type"
///
- public string Max { get; set; }
+ public string? Max { get; set; }
///
/// Used for Match = "regex"
///
- public string Regex { get; set; }
+ public string? Regex { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/Metadata.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/Metadata.cs
index 4036b1ef..d08e78e1 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/Metadata.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/Metadata.cs
@@ -5,7 +5,7 @@ namespace WireMock.Pact.Models.V2;
public class Metadata
{
- public string PactSpecificationVersion { get; set; }
+ public required string PactSpecificationVersion { get; set; }
- public PactSpecification PactSpecification { get; set; } = new PactSpecification();
+ public required PactSpecification PactSpecification { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/Pact.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/Pact.cs
index 90ae6f29..ac3799c7 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/Pact.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/Pact.cs
@@ -1,17 +1,15 @@
// Copyright © WireMock.Net
#pragma warning disable CS1591
-using System.Collections.Generic;
-
namespace WireMock.Pact.Models.V2;
public class Pact
{
- public Pacticipant Consumer { get; set; }
+ public required Pacticipant Consumer { get; set; }
- public List Interactions { get; set; } = new List();
+ public required List Interactions { get; set; } = [];
- public Metadata Metadata { get; set; }
+ public Metadata? Metadata { get; set; }
- public Pacticipant Provider { get; set; }
+ public required Pacticipant Provider { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/PactRequest.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/PactRequest.cs
index 6c99359b..dd261172 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/PactRequest.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/PactRequest.cs
@@ -1,7 +1,6 @@
// Copyright © WireMock.Net
#pragma warning disable CS1591
-using System.Collections.Generic;
using WireMock.Constants;
namespace WireMock.Pact.Models.V2;
@@ -10,9 +9,9 @@ public class PactRequest
{
public IDictionary? Headers { get; set; }
- public string Method { get; set; } = HttpRequestMethod.GET;
+ public required string Method { get; set; } = HttpRequestMethod.GET;
- public string? Path { get; set; } = "/";
+ public required string Path { get; set; } = "/";
public string? Query { get; set; }
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/PactResponse.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/PactResponse.cs
index 9cb2e1f4..fc408171 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/PactResponse.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/PactResponse.cs
@@ -1,8 +1,6 @@
// Copyright © WireMock.Net
#pragma warning disable CS1591
-using System.Collections.Generic;
-
namespace WireMock.Pact.Models.V2;
public class PactResponse
@@ -11,5 +9,5 @@ public class PactResponse
public IDictionary? Headers { get; set; }
- public int Status { get; set; } = 200;
+ public required int Status { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/PactRust.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/PactRust.cs
index 42ec53aa..b14eb52e 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/PactRust.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/PactRust.cs
@@ -5,9 +5,9 @@ namespace WireMock.Pact.Models.V2;
public class PactRust
{
- public string Ffi { get; set; }
+ public required string Ffi { get; set; }
- public string Mockserver { get; set; }
+ public required string Mockserver { get; set; }
- public string Models { get; set; }
+ public required string Models { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/PactSpecification.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/PactSpecification.cs
index 081e906e..db8d1880 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/PactSpecification.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/PactSpecification.cs
@@ -5,5 +5,5 @@ namespace WireMock.Pact.Models.V2;
public class PactSpecification
{
- public string Version { get; set; } = "2.0";
+ public required string Version { get; set; } = "2.0";
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/Pacticipant.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/Pacticipant.cs
index c55e8919..8febc2f5 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/Pacticipant.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/Pacticipant.cs
@@ -5,5 +5,5 @@ namespace WireMock.Pact.Models.V2;
public class Pacticipant
{
- public string Name { get; set; }
+ public required string Name { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Pact/Models/V2/ProviderState.cs b/src/WireMock.Net.Minimal/Pact/Models/V2/ProviderState.cs
index 6e597b04..bef7e8bc 100644
--- a/src/WireMock.Net.Minimal/Pact/Models/V2/ProviderState.cs
+++ b/src/WireMock.Net.Minimal/Pact/Models/V2/ProviderState.cs
@@ -7,7 +7,7 @@ namespace WireMock.Pact.Models.V2;
public class ProviderState
{
- public string Name { get; set; }
+ public required string Name { get; set; }
- public IDictionary Params { get; set; }
+ public IDictionary? Params { get; set; }
}
\ No newline at end of file
diff --git a/src/WireMock.Net.Minimal/Serialization/PactMapper.cs b/src/WireMock.Net.Minimal/Serialization/PactMapper.cs
index c500840d..565f02cb 100644
--- a/src/WireMock.Net.Minimal/Serialization/PactMapper.cs
+++ b/src/WireMock.Net.Minimal/Serialization/PactMapper.cs
@@ -1,8 +1,5 @@
// Copyright © WireMock.Net
-using System;
-using System.Collections.Generic;
-using System.Linq;
using WireMock.Admin.Mappings;
using WireMock.Extensions;
using WireMock.Pact.Models.V2;
@@ -28,7 +25,8 @@ internal static class PactMapper
var pact = new Pact.Models.V2.Pact
{
Consumer = new Pacticipant { Name = consumer },
- Provider = new Pacticipant { Name = provider }
+ Provider = new Pacticipant { Name = provider },
+ Interactions = []
};
foreach (var mapping in server.MappingModels.OrderBy(m => m.Guid))
@@ -42,7 +40,7 @@ internal static class PactMapper
var interaction = new Interaction
{
- Description = !string.IsNullOrWhiteSpace(mapping.Description) ? mapping.Description : mapping.Title ?? string.Empty,
+ Description = mapping.Description ?? mapping.Title ?? string.Empty,
Request = MapRequest(mapping.Request, path),
Response = MapResponse(mapping.Response)
};
@@ -65,13 +63,8 @@ internal static class PactMapper
};
}
- private static PactResponse MapResponse(ResponseModel? response)
+ private static PactResponse MapResponse(ResponseModel response)
{
- if (response == null)
- {
- return new PactResponse();
- }
-
return new PactResponse
{
Status = MapStatusCode(response.StatusCode),