I have similar openapi.yml spec file:
openapi: 3.0.1
info:
title: some title
version: "4"
paths:
/users/{userId}/data:
get:
summary: some summary
description: some description
operationId: userData
parameters:
- name: some-token
in: header
description: desc
required: true
schema:
type: string
example: "tokenExample"
...
- name: userId
in: path
description: desc
required: true
schema:
type: string
example: "someID"
responses:
"200":
description: desc
content:
"application/json":
schema:
$ref: '#/components/schemas/DataModel'
components:
schemas:
DataModel:
type: object
properties:
data1:
type: integer
format: int32
data2:
type: integer
format: int32
data3:
type: integer
format: int32
Test execution giving me such result:
request:
method: GET
uri: /users/<someID>/data
headers:
some-token: 389fe056-e904-48fd-8d89-caaf8769ab84
...
User-Agent: Dredd/14.0.0 (Linux 5.10.104-linuxkit; x64)
body:
expected:
headers:
Content-Type: application/json; charset=utf-8
body:
{
"data1": 0,
"data2": 0,
"data3": 0
}
statusCode: 200
actual:
statusCode: 200
headers:
server: Apache-Coyote/1.1
set-cookie: rememberMe=deleteMe; Path=/somepath; Max-Age=0; Expires=Thu, 17-Nov-2022 08:41:46 GMT; Secure
content-type: application/json;charset=UTF-8
transfer-encoding: chunked
date: Fri, 18 Nov 2022 08:41:46 GMT
connection: close
bodyEncoding: utf-8
body:
{
"data1": 0,
"data2": 0,
"data3": 0
}
Body and status code matched perfectly, but something, maybe headers, failing verification. How can I get passed verification for this test? Is headers matching necessary for passing test? If yes, how achieve headers matching?
PS. I now that is very similar question already on Stackoverflow, but it was asked pretty long time ago, so I decided to refresh it and some more details.
Running
dredd
with debug log level (--logLevel=debug) helped me to recognize the problem. That needed to be exactly"application/json;charset=utf-8"
in content response, instead of"application/json"