Hello folks, I’ve started working on a Bi-Directio...
# pactflow
k
Hello folks, I’ve started working on a Bi-Directional Contract Testing POC and stumbled on a contract violation during the first few basic attempt. After some searching, I’m still not quite sure what the problem might be and so decided to try and ask here. The verification fails in the consumer contract with the reasoning, that no schema seems to have been found for the response body. Never the less from my limited understanding of Pactflow, it seemed to me it should have been provided as part of the API specification published from the provider. Could you help me identify what it is I’m doing wrong exactly? Thanks!
m
Could you please attach the pact file and OAS for us to review?
k
m
You’ll need to specify the content type in the response to be explicitly
application/json
i.e.
Copy code
"content": {
              "application/json": { <---------
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Project"
                  }
                }
              }
            }
The header
access-control-allow-origin
is also not present in the OAS. If you update the content type and add the new header, it should pass.
k
Thank you very much. Adding content type did the trick.
👍 1
a
I am currently facing an issue which seems to be the same. I have “* */ *” as content type both in the OAS specification and in the generated pact, and I stil have that “*No schema found for response body” error. Do you think it is the same issue ?
m
I think you're best specifying the actual content type.
Have you tried?
a
No, not yet, as I’d have to change either the endpoints implementations or how the OAS is generated, but I’ll give it a try.
@Matt (pactflow.io / pact-js / pact-go) you were totally right, specifying application/json in the oas does the trick.
🙌 1