Request Schema logo

Request Schema

By RightCO

A Strapi plugin that allows to create schemas that the request must follow.

Latest version

v1.1.1

released December 29, 2025

npm install strapi-plugin-request-schema

Strapi v5 - Request Schema

A plugin for Strapi Headless CMS that provides a way to define a schema at the routes level that will be used to parse the data that is sent in the request.

Features

  • Allows the creation in the route config object a schema follow a set of rules
  • When calling a route it will search if there is a defined schema and then parse the request data
  • Provides a parsed and expected data, following the defined schema, when accessing the request data at the controllers/services

How it works

When exporting, non GET, routes at /api/{api}/routes/{routes}.(js|ts) it is possible to add extra data into the config object.

The plugin searches for routes that have either body or files inside the config object.

Those extra configurations have to follow a set of defined rules when creating the schemas.

Body Schema

Inside the body object can exist any key, but the pair value has to follow a set of rules:

  • Be any of the literal values: "string", "[string]", "number", "[number]", "boolean", "[boolean]"
  • Be a object, repeating the rules that apply on the main body object
    • Objects can be nested inside each other without any max depth
  • Be a array of objects, where only a first element must exist

NOTE: The literals that are inside [] mean that they are expected to be a array of the type inside of it. For example [string] is expected to be a array of strings.

{ method: "POST", path: '...', handler: '...', config: {
    body: {
        foo: "string" | "[string]" | "number" | "[number]" | "boolean" | "[boolean]",
        bar: {
            foo: "string" | "[string]" | "number" | "[number]" | "boolean" | "[boolean]",
            bar: {
                foo: "string" | "[string]" | "number" | "[number]" | "boolean" | "[boolean]",
            },
        },
        foobar: [{
            foo: "string" | "[string]" | "number" | "[number]" | "boolean" | "[boolean]",
            bar: {
                foo: "string" | "[string]" | "number" | "[number]" | "boolean" | "[boolean]",
            },
        }],
    }
}}

Files Schema

Inside the files object can exist any key but the pair value has to be any of the literal values: "file", "[file]"

{ method: "POST", path: '...', handler: '...', config: {
    files: {
        foo: "file" | "[file]",
        bar: "file" | "[file]",
    }
}}

Compatibility

The plugin is currently tested and functional using strapi version 5.24.0

Installation

# Using NPM
npm install strapi-plugin-request-schema

Configuration

As all other plugins, strapi allows to disable the plugin in /config/plugins.(js|ts) without having to uninstall it.

export default {
    // ...
    "strapi-plugin-request-schema": {
        enabled: false,
    },
    // ...
}

Submit your content

Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.

Submit
Submit your content