TemplateThe file path to the OpenAPI specification file.
The Express application instance.
Optional configuration options for the request sender.
A promise that resolves to a RequestSender object.
import express from 'express';
import { createRequestSender } from './requestSender';
import type { paths, operations } from './openapi';
const app = express();
const openapiFilePath = './openapi3.yaml';
const requestSender = await createRequestSender<paths, operations>(openapiFilePath, app);
// Using operation name
const response1 = await requestSender.getUsers();
// Using path and method
const response2 = await requestSender.sendRequest({
method: 'get',
path: '/simple-request'
});
Creates a request sender object that can be used to send fake HTTP requests using supertest based on an OpenAPI specification. The openapi types should be generated using the openapi-typescript package.
Paths - The type representing the paths defined in the OpenAPI specification. Operations - The type representing the operations defined in the OpenAPI specification.