Socket
Book a DemoInstallSign in
Socket

confident

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confident

Use Express with OpenAPI / Swagger

latest
Source
npmnpm
Version
5.2.1
Version published
Weekly downloads
9
Maintainers
3
Weekly downloads
 
Created
Source
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

  • Starting from scratch (4m53s)

See also

Keywords

express

FAQs

Package last updated on 10 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts