Open Zubnix opened 2 years ago
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();
});
example openapi doc:
/v1/report/generate:
post:
tags:
- reports
description: '...'
summary: '...'
operationId: generateReport
requestBody:
$ref: '#/components/requestBodies/........'
responses:
'201':
content:
application/octet-stream:
schema:
type: string
format: binary
description: ......
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.