Confident treats your API specification (a .json file) as the source of truth for express routes, API documentation, and request/response validation.
- Works with existing Express app.
- Everything is opt-in. Incrementally integrate or eject.
- Validate your API schema.
- Validate requests.
- Validate responses.
- Serves up API documentation.
- Serves up /api.json.
- Suggests schemas to increase coverage.
- Supports basePath.
npm install confident --save
{
"swagger": "2.0",
"info": {
"title": "Hello World",
"version": "1.0.0"
},
"paths": {
"/hello": {
"get": {
"summary": "Say hello to the world",
"operationId": "greet",
"responses": {
"200": {
"description": "Sweet success"
}
}
}
}
}
}
const confident = require('confident')
const express = require('express')
const app = express()
function greet (req, res) {
res.json('Hello, world.')
}
app.use(confident({
specification: './api.json',
docsEndpoint: '/docs',
operations: { greet }
}))
app.listen(3000)
http://localhost:3000/docs