Route Custom Data
Use custom data from OpenAPI documents in policies and handlers.
Route Custom Data#
This sample demonstrates how to read custom data from a route configuration.
Use this example locally#
To develop with this example locally, you can create a new Zuplo project using our CLI
npx create-zuplo-api@latest my-api --example route-custom-data
Then, in the project directory run the following commands:
npm install
npm run dev
Then complete the following setup steps:
1/ Set Custom Data#
In the routes.oas.json
set a custom value inside of the route configuration as shown below. In this case, the x-custom
property is used, but any property that starts with x-
can be used.
{
"paths": {
"/custom-data": {
"post": {
"x-custom": {
"isSet": true,
"hello": "world"
}
}
}
}
}
2/ Read Custom Data#
From a handler or policy custom data can be read using ZuploContext
as shown below.
const data = context.route.raw<{ "x-custom": { hello: boolean } }>();
Discover More Examples
Remote MCP Server with OAuth
A remote MCP Server that shows how to setup OAuth authentication with Auth0
Dev Portal with API Keys
An example of a Zuplo Dev Portal with support for self-serve API key creation.
Remote MCP Server
Create a remote MCP server for an API with authentication and additional security policies.
Metering with OpenMeter
Meter requests, enforce plan limits and monetize your API by integrating Zuplo with OpenMeter.