confident

5.2.1 • Public • Published
Swagger wagon

Confident treats your API specification (a .json file) as the source of truth for express routes, API documentation, and request/response validation. It's your swagger wagon.

Features

  • 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.

Get started

npm install confident --save

api.json

{
  "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"
          }
        }
      }
    }
  }
}

index.js

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)

Generated documentation

http://localhost:3000/docs

screenshot

Tutorial video

See also

Readme

Keywords

Package Sidebar

Install

npm i confident

Weekly Downloads

85

Version

5.2.1

License

MIT

Last publish

Collaborators

  • jozomby
  • aindeev
  • aaronshaf