Skip to content

Japa plugin to perform assertions against an OpenAPI spec

License

Notifications You must be signed in to change notification settings

japa/openapi-assertions

Repository files navigation

@japa/openapi-assertions


gh-workflow-image npm-image license-image

Introduction

This package contains the OpenAPI Assertion tests that used to be included in @japa/assert

Installation

Install the package from the npm registry as follows:

npm i -D @japa/openapi-assertions

yarn add -D @japa/openapi-assertions

Official Documentation

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)
})

Contributing

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.

Code of Conduct

In order to ensure that the japa community is welcoming to all, please review and abide by the Code of Conduct.

License

@japa/openapi-assertions is open-sourced software licensed under the MIT license.

About

Japa plugin to perform assertions against an OpenAPI spec

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published