You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See error (please paste error output or a screenshot)
Error: expect(received).toSatisfyApiSpec() // Matches 'received' to a response defined in your API spec, then validates 'received' against it
expected received to satisfy the '200' response defined for endpoint 'GET /webfd/{fd}' in your API spec
received did not satisfy it because: response must be string
received contained: { body: <Buffer 01 02> }
The '200' response defined for endpoint 'GET /webfd/{fd}' in API spec: {
'200': {
description: 'Content sent succesfully.',
content: {
'application/octet-stream': { schema: { type: 'string', format: 'binary' } }
}
}
}
What did you expect to happen instead?
Verification should succeed.
Are you going to resolve the issue?
No, as I don't know here to look.
The text was updated successfully, but these errors were encountered:
Thanks @Zubnix! Would you posting a reproduction link / example of how you receive a response as a Buffer? Then I can check the code and point you / someone else in the right direction 🙂
I also have the same issue with this in a Nest project: I have an endpoint generating a PDF and in the controller I do nothing else just returning a StreamableFile. This StreamableFile gets the input as a Buffer from puppeteer - pretty simple setup.
When running test again the openapi documentation using supertest, in the console it prints out as a buffer. See examples below from my code:
received did not satisfy it because: response must be string
received contained: {
body: <Buffer 25 50 44 46 2d 31 2e 34 0a 25 d3 eb e9 e1 0a 31 20 30 20 6f 62 6a 0a 3c 3c 2f 43 72 65 61 74 6f 72 20 28 43 68 72 6f 6d 69 75 6d 29 0a 2f 50 72 6f 64 ... 12824 more bytes>
}
test:
test('returns pdf with application/octet-stream', async () => {
const agent = supertest(app.getHttpServer());
const res = await agent
.post('/v1/report/generate')
.send([......]);
expect(res).toSatisfyApiSpec();
});
Are you using jest or chai?
Jest
Are you using OpenAPI 2, 3.0.X, or 3.1.0?
3.0.x
Describe the bug clearly
Verification fails when using binary string format, incorrectly expects plain string.
Steps to reproduce the bug:
What did you expect to happen instead?
Verification should succeed.
Are you going to resolve the issue?
No, as I don't know here to look.
The text was updated successfully, but these errors were encountered: