Comments (10)
The consumer runs successfully if I use the CamelCasePropertyNamesContractResolver, and generates a pact with lowercase model names, but the provider verification fails. The provider passes if I use lowercase model names.
I can't make sense of this as it seems to contradict itself. What does the provider need to pass - lower case or upper case? What does the consumer need (the correct answer is "the same as the provider" 😆 )
from pact-net.
Both the provider and consumer are expecting upper case, but the pact is generating it as lowercase.
from pact-net.
If they're expecting upper case, why are the models you use using camel casing?
from pact-net.
Sorry, both are expecting camel case, but its a single word so the only difference is that the first letter is uppercase
from pact-net.
Maybe I'm reading your response wrong but if the first letter is / should be uppercase, that's not camel casing.
Can you give an example of the model (or one of it properties) and how it appears in the contract vs. how it is expected by the consumer / should be returned by the provider?
from pact-net.
Here is the Consumer model:
public class StreetResponse
{
public string Street { get; set; }
}
Here is the Provider model:
public class StreetResponse
{
public string Street { get; set; }
}
Here is what is being saved in the contract:
"response": {
"body": {
"street": "Mock Street"
},
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"status": 200
}
Both the consumer and provider have an uppercase 'S', but the contract uses a lowercase 's', which is causing the pact verification to fail
from pact-net.
Your consumer tests have a camel case property resolver set in the serialisation options, which will lower case the first letter and then upper case each word after that, like firstName
So, if you don't want the contract to publish with a lower case leading character then you'll need to stop telling it to do that by removing that from the serialisation options.
from pact-net.
I can confirm this, just tested this in my own project and changing
var config = new PactConfig
{
PactDir = $"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.FullName}{Path.DirectorySeparatorChar}pacts",
LogLevel = PactLogLevel.Debug,
DefaultJsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(), // Consumer passes because of this
}
};
to
var config = new PactConfig
{
PactDir = $"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.FullName}{Path.DirectorySeparatorChar}pacts",
LogLevel = PactLogLevel.Debug,
DefaultJsonSettings = new JsonSerializerSettings()
};
will generate a contract with Pascal-cased elements / model names.
from pact-net.
The CamelCasePropertyNamesContractResolver change has done the trick. Also, the way I was using the HttpClient was making requests become lowercase, which complicated things.
It's working now. Thanks for the help all, I really appreciate it.
from pact-net.
Awesome, thanks for confirming - thanks all for your help. Will close this one off.
from pact-net.
Related Issues (20)
- Pact Merging Creates Duplicate Interactions HOT 4
- RFC: Pact Plugins HOT 6
- Pact json being overwritten by each test in C# .NET HOT 7
- Pact request body with inner object gives internal server error in Pact Net HOT 6
- Dynamic date in request HOT 3
- RFC: Add linux-musl-x64 Runtime Support HOT 3
- RFC: Add Linux (libc)-ARM Runtime Support HOT 2
- RFC: Support System.Text.Json default polymorphic type discriminator when using .WithJsonBody() HOT 2
- DevContainer: Unable to load shared library 'pact_ffi' or one of its dependencies HOT 1
- DevContainer: Unable to load shared library 'pact_ffi' or one of its dependencies wit PactNet.5.0.0-beta.2 HOT 3
- Match.Type throws an exception on an attribute of type Object HOT 4
- Version 5 roadmap HOT 1
- RFC: Distinguish technical failures when verifying pacts HOT 6
- RFC: add failIfNoPactsFound flag to Provider tests HOT 3
- Multiple integrations with same Consumer and Provider cause to pact file write errors HOT 7
- RFC: EachKey and EachValue Matcher HOT 1
- Documentation Confusion HOT 1
- Multiple provider state middleware HOT 2
- Deadlock issue while running test HOT 3
- Error Starting Messaging Provider
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pact-net.