Hi Pactflow team, Our bi-directional contracts sta...
# pactflow
t
Hi Pactflow team, Our bi-directional contracts started failing with no changes on our side. I found that changes to how you deal with additionalProperties got released recently. I don’t quite understand how to fix that on our side though. We don’t set
additionalProperties: false
in our schema, should we do it on each object type to be able to pass validation now?
for more context: we do have fields like
properties
or
metadata
where we expect any field to be send and we store the object as is later in the db. Now all such fields trigger compatibility errors
must NOT have additional properties
even if I explicitly set
additionalProperties: true
m
additionalProperties can also accept a schema of allowed types, have you considered this case? It's a tricky problem. We've seen a lot of examples where it's set to true but for bad reasons. We may need to consider allowing an application to configure that behaviour
t
additionalProperties can also accept a schema of allowed types, have you considered this case?
yeah, but it’ll be a temporary solution for us as if tests start sending different fields in the object (and we don’t care that they change), we will have to update provider contract again. As I still want to test such a field and have a stable contract, I’d like to have a way to say “ok, I know the risks, please apply additionalProperties: true”
thanks for your reply! I’ll apply your suggestion
m
cc @Yousaf Nabi (pactflow.io).
👀 1
I think I’ve created a type that will work for you. I’ll publish an example shortly
🙇‍♀️ 1
👌 1
I’ve also realised you’re sending this on the request side - the change above probably is most impactful on the response side. The issue is it’s hard for us to detect if it’s in a
definition
- it could be used in both contexts.
I think this expresses a JSON type that is equivalent to
additionalProperties: true
.
t
Thanks a lot for the example @Matt (pactflow.io / pact-js / pact-go)!
I’ve also realised you’re sending this on the request side
yeah, that’s true. anyway it’s the part the response side is responsible for. so, it does make sense to update the provider’s contract.
🙌 1
m
You’re welcome - do you think it will help?
t
sorry for delay! yes, this helps!
🙌 1
m
Great!