Optic for Express JS
Optic's documenting middleware for Express JS. This package supports APIs written in Javascript, Typescript, or ReasonML and can be used with the testing framework of your choice.
Usage
- Install as a dev dependency
npm install @useoptic/document-express --save-dev
- Before testing your Express App, wrap it in the documenting middleware.
import withOptic from '@useoptic/document-express'
import {app} from '../server.js'
const appWithOptic = withOptic(app)
it('can get a list of users', (done) => {
request(appWithOptic)
.get('/users')
.expect(200, done)
})
- Consider wrapping the Express App within a shared test fixture so it's easier to integrate Optic with all of your tests.
Next Steps
Once you've setup the documenting middleware, review the Optic docs to finish setting up Optic for your API