Closed
Description
Hi guys, love the tool but can use some help.
I've been trying to create a contract with enum values, I get number but I want the string value as my provider returns strings. How can I make sure the contract will contain "gender" : "Male" instead of "gender": 0? Below is a simplified example, however the class I'm using has many many enums.
using IPactBuilderV4;
Let's say I have this object:
public class Person {
public Gender Gender {get; set;}
}
public enum Gender {
[Display(Name = "Male")]
Male
}
And this is my consumer contract code (simplified snippet):
var person = new Person()
{
Gender = Gender.Male,
};
this.pact
.UponReceiving("a for a person")
.Given("a person exists in database")
.WithRequest(HttpMethod.Get, $"/person")
.WillRespond()
.WithStatus(HttpStatusCode.OK)
.WithJsonBody(Match.Type(person);
I get this contract (snippet)
...
"response": {
"body": {
"content": {
"gender": 0
},
"contentType": "application/json",
"encoded": false
},
...
Metadata
Metadata
Assignees
Labels
No labels