I cannot find a resource to learn how to use this thing to send binary data. The following fails with status 415.
const fs = require('fs');
const SwaggerParser = require('swagger-parser');
const Swagger = require('swagger-client');
async function getClient() {
let spec = await SwaggerParser.dereference('path/to/openapi.yaml')
spec.servers = [{url: 'http://localhost:8080'}];
return (await Swagger({spec})).apis.default;
}
(async function() {
let client = getClient(); // client
let data = fs.readFileSync('path/to/file.txt'); // buffer
let response = client.createWithBinary(data) // <-- this is how we usually set req params and it fails
})();
The contract is open api 3 and expects an octet-stream in the request body:
...
paths:
/binary:
post:
operationId: createWithBinary
description: Create a resource by uploading binary data
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
200:
description: ...
The server works as expected with swagger-ui so the problem is not there. Any help/resource would be greatly appreciated.