ZuploZuplo
LoginSign Up
  • Documentation
  • API Reference
Introduction
Getting Started
    Develop using the Portal
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingMCP - Quick start
    Develop Locally
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth
Concepts
Development
    CORSEnvironment VariablesBranch-Based DeploymentsTestingTroubleshootingGitOps vs TerraformCustom Code
    Local Development
    Guides
      Advanced Path MatchingAPI VersioningOpenAPI Server URLsConvert URLs to OpenAPIOpenAPI Extension DataPath Modification ScriptsOpenAPI OverlaysCanary Routing for EmployeesGeolocation Backend RoutingUser-Based Backend RoutingBypass a PolicyTesting GraphQL QueriesHealth ChecksPerformance TestingTroubleshooting Slow ResponsesNon-Standard PortsHandling FormDataS3 Signed URL UploadsCheck IP AddressLazy Load ConfigurationSharing Code Across ProjectsBackstage IntegrationGitHub Action Automation
Policies
Handlers
API Keys
MCP Server
MCP Gateway
AI Gateway
Developer Portal
Monetization
Deploying & Source Control
Observability
Networking & Infrastructure
Account Management
Programming API
Build with AI
Zuplo CLI
Migration Guides
Platform LimitsSecuritySupportTrust & ComplianceChangelog
powered by Zudoku
Guides

Using the OpenAPI Extension Data in Code

The OpenAPI specification allows for the use of vendor-specific extensions to add custom configuration to the API definition. An example of this is the x-internal extension, which can be used to mark an API as internal and not intended for public use.

This same type of extensibility can be used to add custom data to the OpenAPI file which can then be used inside of your Zuplo API Gateway. This data can be used to configure the behavior of the API Gateway, such as setting up rate limiting, authentication, or other custom behavior.

In this article, we will show you how to use the OpenAPI extension data in your code.

Custom Data in the OpenAPI File

To add custom data to your OpenAPI file, you can use the x- prefix followed by the name of the extension. Add this extension to the operation (for example the get, post, etc. section). For example, to add a custom field called my-custom-config to the OpenAPI file, you would use the following syntax:

config/routes.oas.json
{ "paths": { "/hello": { "x-zuplo-path": { "pathMode": "open-api" }, "get": { "summary": "Hello World", "x-my-custom-config": 10, "x-zuplo-route": { "corsPolicy": "none", "handler": { "export": "default", "module": "$import(./modules/route-data)", "options": {} }, "policies": { "inbound": [] } }, "operationId": "8914135b-d7b5-49fc-9e41-a8256a0dcf93" } } } }

Using the Custom Data in Code

To use the custom data in your code, you can access it through the ZuploContext object via the route.raw method. The route.raw method returns an object that contains all of the values in the operation.

modules/route-data.ts
import { ZuploContext, ZuploRequest } from "@zuplo/runtime"; export default async function (request: ZuploRequest, context: ZuploContext) { const routeData = context.route.raw(); const myCustomConfig = routeData["x-my-custom-config"]; // Logs "Customer config, 10" context.log.debug("Custom config", myCustomConfig); return "Hello"; }
Edit this page
Last modified on March 27, 2026
Convert URLs to OpenAPIPath Modification Scripts
On this page
  • Custom Data in the OpenAPI File
  • Using the Custom Data in Code
JSON
TypeScript