Stefan Tertan
11/04/2022, 2:22 PMPortalUI & ProfileService.
I have the OpenAPI specification for PortalService, which includes the following endpoints:
• GET /profiles - return 200 or 401
• GET /profiles/{id} - return 200 or 400 or 404 or 401
They are both set to use JWT authentication.
For the consumer contract, I'm running the tests shown in the screenshot (I have also attached the generated pact).
On contract comparison, I get a few errors.
For both endpoints I get one about Request Authorization header is missing but is required by spec file. It is true that the Authorization header is required, but I also want to ensure not specifying it returns a 401. This example on StackOverflow shows how to make security optional in the OpenAPI spec, but that might lead to the API implementation lacking proper security of endpoints (and a tool such as Dredd would likely not catch that, since the spec says it's optional). Any idea how to deal with this issue?
For get /profiles I get additional Response Body is Incompatible errors:
• Response body is incompatible with the response body schema in the spec file: should be array
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - content
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - contentType
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - encoded
The response in the contract looks like this:
"response": {
"body": {
"content": [],
"contentType": "application/json",
"encoded": false
},
"headers": {
"Content-Type": [
"application/json; charset=utf-8"
]
},
"status": 200
}
Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - encoded
Mismatched Pact Path:
[root].interactions[1].response.body
Mismatched Provider Path:
[root].paths./profiles.get.responses.200.content.application/json; charset=utf-8.schema.additionalPropertiesInitially I had
additionalProperties set to false in the schema for Profile, but even after removing that, deleting the pacts & re-publishing, it still points to that under `Mismatched Provider Path`:
Profile:
type: object
required:
- id
- username
- picture
additionalProperties: false
properties:
id:
type: string
username:
type: string
picture:
type: stringStefan Tertan
11/04/2022, 2:24 PMResponse Body Is Incompatible errorsTimothy Jones
11/04/2022, 11:47 PMTimothy Jones
11/04/2022, 11:48 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Stefan Tertan
11/07/2022, 3:05 PMMatt (pactflow.io / pact-js / pact-go)
Timothy Jones
11/08/2022, 12:18 AM