This package contains the OpenAPI Assertion tests that used to be included in @japa/assert
Install the package from the npm registry as follows:
npm i -D @japa/openapi-assertions
yarn add -D @japa/openapi-assertions
You can use the assertion package with the @japa/runner
as follows, registering an OpenAPI Schema:
import { openapi } from '@japa/openapi-assertions'
configure({
plugins: [
openapi({
schemas: [new URL('../api-spec.json', import.meta.url)],
}),
],
})
In tests you can validate API responses using the assert.isValidApiResponse
method.
test('get users', ({ assert }) => {
const response = await supertest(baseUrl).get('/users')
assert.isValidApiResponse(response)
})
One of the primary goals of japa is to have a vibrant community of users and contributors who believes in the principles of the framework.
We encourage you to read the contribution guide before contributing to the framework.
In order to ensure that the japa community is welcoming to all, please review and abide by the Code of Conduct.
@japa/openapi-assertions is open-sourced software licensed under the MIT license.