Hello, I encountered a response-body validation er...
# pactflow
t
Hello, I encountered a response-body validation error. The server/producer defines the "400 Bad Request" response body as follows:
Copy code
responses:
  error-400-bad-request:
    description: ''
    content:
      application/vnd.api+json:
        schema:
          type: object
          properties:
            errors:
              type: array
              items:
                type: object
                properties:
                  source:
                    type: object
                    properties:
                      parameter:
                        type: string
                      pointer:
                        type: string
                  code:
                    type: string
                    enum:
                      - BAD_REQUEST
                      - UNPROCESSABLE_ENTITY
                  status:
                    type: string
                    enum:
                      - '400'
                      - '422'
                  details:
                    type: string
                required:
                  - code
                  - status
          required:
            - errors
        examples:
          Example 1:
            value:
              errors:
                - source:
                    parameter: id
                  detail: is in invalid format
                  code: BAD_REQUEST
                  status: '400'
Example:
Copy code
{
  "errors": [
    {
      "source": {
        "parameter": "id"
      },
      "detail": "is in invalid format",
      "code": "BAD_REQUEST",
      "status": "400"
    }
  ]
}
The client/consumer used the following mocked response body:
Copy code
{
  errors: [
    {
      status: "400",
      code:   "INVALID_QUERY_PARAMETER",
      source: {
        params: "foobar"
      }
    }
  ]
}
It expected the undefined
params
instead of
parameters
, but pactflow didn't detect an error.
@Beth (pactflow.io/Pact Broker/pact-ruby), @Matt (pactflow.io / pact-js / pact-go) is this a know issue or should I open a bug ticket somewhere?
b
Have you checked your “additionalProperties” parameter?
99% of unexpected behaviour seems to be because of that being set incorrectly!
I haven’t done any work on the oas/pact verifier logic though (we’re currently using the swagger mock validator under the hood https://www.npmjs.com/package/swagger-mock-validator) so I’m not the best person to advise you on this.
I’ve just checked with the team. Apparently the additionalProperties is set by default now, so ignore that comment. Please do send an email to support@pactflow.io and provide the relevant pact and OAS.
thankyou 3 1
1