Back to blog
Guides & Tutorials

Reva: Validate requests with OpenAPI in Node.js

Validating API requests shouldn't be a hassle. Why write validation code by hand when we have OpenAPI documents that describe every endpoint? To address this problem we built Reva, a simple Node.js request validator based on OpenAPI.

Elias MeireElias Meire

Elias Meire

2 min read
Reva: Validate requests with OpenAPI in Node.js

Validating API requests shouldn't be a hassle. Why write validation code by hand when we have OpenAPI documents that describe every endpoint? To address this problem we built Reva, a simple Node.js request validator based on OpenAPI.

As an API-first company, we try to deliver the best developer experience possible with our APIs. API validation has a huge role to play in DX. Developers should get immediate and precise feedback when their requests aren't valid. Reva leverages our public OpenAPI specifications to do exactly that.

Here are some highlights of @apideck/reva

  • ✅ Complete: Reva validates all OpenAPI parameter types and request body
  • 😄 Human-readable error messages powered by our better-ajv-errors package.
  • đŸ§© Flexible: works with any Node.js framework and serverless provider
  • đŸȘ¶ Small footprint: < 50kB
  • đŸ‘©â€đŸ’» High quality TypeScript definitions

Ready to try it out? Install Reva through npm.

npm i @apideck/reva

Using Reva

After installing Reva, import the Reva class, and create a new instance.

To validate a request you need a request object and an OpenAPI operation. No need to load a complete OpenAPI document to validate a single endpoint.

A request can have the following properties: body, queryParameters, pathParameters and headers. None of them are required. You can, for example, use Reva to only validate query parameters.

import { Reva } from '@apideck/reva';

const reva = new Reva();

const result = reva.validate({
  operation, // OpenAPI operation
  request: {
    headers: { 'X-My-Header': 'value', Cookie: 'Key=Value' },
    pathParameters; { id: 'ed55e7a3' },
    queryParameters; { search: 'foo' },
    body: {},
  },
});

if (result.ok) {
  // Valid request!
} else {
  // Invalid request, result.errors contains validation errors
  console.log(result.errors);
}

Detailed docs can be found on GitHub.

Feedback welcome

We built Reva to solve our own need for easy validation based on OpenAPI. We hope you find it useful too. Any feedback is welcome, looking forward to collaborate further on GitHub.

Ready to get started?

Scale your integration strategy and deliver the integrations your customers need in record time.

Ready to get started?
Trusted by
Nmbrs
Benefex
Principal Group
Invoice2go by BILL
Trengo
MessageMedia
Lever
Ponto | Isabel Group
Apideck Blog

Insights, guides, and updates from Apideck

Discover company news, API insights, and expert blog posts. Explore practical integration guides and tech articles to make the most of Apideck's platform.

A Primer on the Model Context Protocol (MCP)
AIIndustry insights

A Primer on the Model Context Protocol (MCP)

In this article, we dive deep into what MCP actually is, how it works behind the scenes, and why it’s being called the “USB-C for AI models.” You’ll explore how it simplifies AI integrations, the roles of Hosts, Clients, and Servers, and the security risks developers need to keep in mind.

Saurabh Rai

Saurabh Rai

7 min read
Understanding RAG: Retrieval Augmented Generation Essentials for AI Projects
AIIndustry insights

Understanding RAG: Retrieval Augmented Generation Essentials for AI Projects

Large Language Models (LLMs) are powerful, but they don't inherently know your specific company procedures, project details, or internal knowledge base. You can bridge this gap and make AI reliably answer questions using your private data by using retrieval-augmented generation (RAG). This is a three-article series. In this article, we will go through the basics of RAG, its importance, and an overview of how to build an RAG pipeline and the tools involved.

Saurabh Rai

Saurabh Rai

9 min read
HiBob API Integration Guide
HRISGuides & Tutorials

HiBob API Integration Guide

This guide breaks down how to integrate with the HiBob API, a common request for developers building HRIS integrations. It covers real challenges you’ll face—like authentication setup, handling custom fields, and dealing with rate limits—and walks you through working API examples using Postman. You'll learn how to fetch employee data, manage time-off requests, and structure reliable API calls.

Rexford Ayeh Nyarko

Rexford Ayeh Nyarko

11 min read