GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - CSNW/express-openapi-validator: ๐Ÿฆ‹ Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

1,849 Commits
1,849 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
assets
assets
 
 
examples
examples
 
 
src
src
 
 
test
test
 
 
typings
typings
 
 
.all-contributorsrc
.all-contributorsrc
 
 
.codacy.yml
.codacy.yml
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.gitpod.yml
.gitpod.yml
 
 
.npmignore
.npmignore
 
 
.nycrc
.nycrc
 
 
.prettierrc.json
.prettierrc.json
 
 
.travis.yml
.travis.yml
 
 
CHANGE_HISTORY.md
CHANGE_HISTORY.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
_config.yml
_config.yml
 
 
build.sh
build.sh
 
 
launch.json
launch.json
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
secrets.zip.enc
secrets.zip.enc
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

๐Ÿฆ‹ express-openapi-validator

All Contributors Coverage Status Codacy Badge Gitpod Ready-to-Code

An OpenApi validator for ExpressJS that automatically validates API requests and responses using an OpenAPI 3 specification.

๐Ÿฆ‹express-openapi-validator is an unopinionated library that integrates with new and existing API applications. express-openapi-validator lets you write code the way you want; it does not impose any coding convention or project layout. Simply, install the validator onto your express app, point it to your OpenAPI 3 specification, then define and implement routes the way you prefer. See an example.

Features:

  • โœ”๏ธ request validation
  • โœ”๏ธ response validation (json only)
  • ๐Ÿ‘ฎ security validation / custom security functions
  • ๐Ÿ‘ฝ 3rd party / custom formats / custom data serialization-deserialization
  • ๐Ÿงต optionally auto-map OpenAPI endpoints to Express handler functions
  • โœ‚๏ธ $ref support; split specs over multiple files
  • ๐ŸŽˆ file upload

Docs:

  • ๐Ÿ“– documenation

GitHub stars Twitter URL

NestJS Koa and Fastify now available! ๐Ÿš€

Install

npm install express-openapi-validator

## latest beta
npm install [email protected]

Usage

  1. Require/import the openapi validator
const OpenApiValidator = require('express-openapi-validator');

or

import * as OpenApiValidator from 'express-openapi-validator';
  1. Install the middleware
app.use(
  OpenApiValidator.middleware({
    apiSpec: './openapi.yaml',
    validateRequests: true, // (default)
    validateResponses: true, // false by default
  }),
);
  1. Register an error handler
app.use((err, req, res, next) => {
  // format error
  res.status(err.status || 500).json({
    message: err.message,
    errors: err.errors,
  });
});

Important: Ensure express is configured with all relevant body parsers. Body parser middleware functions must be specified prior to any validated routes. See an example.

Documentation

See the wiki for complete documenation

License

MIT

Buy Me A Coffee

About

๐Ÿฆ‹ Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.