← Back to nodox

Zero-Config Swagger UI from
express-validator Chains

nodox-cli reads your body(), param(), and query() chains at route-registration time and generates interactive Swagger documentation automatically. No wrapper functions needed.

Get started: npx nodox-cli init

No code changes required

Unlike other Swagger generators that require you to wrap your validators or add decorators, nodox-cli reads express-validator chain metadata at the framework level. Your existing routes are already documented.

Your existing code — nothing changes

import express from 'express'
import nodox from 'nodox-cli'
import { body, param, validationResult } from 'express-validator'

const app = express()
app.use(express.json())
app.use(nodox(app))   // ← add this one line

// nodox-cli reads these chains automatically —
// no validate() wrapper needed for express-validator
app.post('/users',
  body('email').isEmail(),
  body('name').isString().notEmpty(),
  body('age').isInt({ min: 0 }).optional(),
  body('role').isIn(['admin', 'user']),
  (req, res) => {
    const errors = validationResult(req)
    if (!errors.isEmpty()) {
      return res.status(400).json({ errors: errors.array() })
    }
    res.status(201).json({ id: 1, ...req.body })
  }
)

// → Visit /__nodox: email detected as string/email,
//   age as integer, role as enum['admin','user']

Type mapping

nodox-cli infers OpenAPI types from your validator method names:

express-validator methodOpenAPI type
isEmail()string, format: email
isURL()string, format: uri
isUUID()string, format: uuid
isISO8601()string, format: date-time
isInt(), isNumeric()integer
isFloat(), isDecimal()number
isBoolean()boolean
isArray()array
isJSON()object
isIn([...])string, enum: [...]
anything elsestring

Supports express-validator v6 (._context) and v7 (.builder), both detected automatically.

Setup in 30 seconds

npm install nodox-cli npx nodox-cli init Full setup guide →

Also supports

nodox-cli reads Zod, Joi, and yup with the same zero-config approach.