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

Script to Convert URL Params to OpenAPI Format

This is an example script that shows how to convert URLs in your Zuplo OpenAPI files to OpenAPI formatted parameters.

Code
import fs from "fs/promises"; import kabab from "kebab-case"; import path from "path"; import { pathToRegexp } from "path-to-regexp"; import prettier from "prettier"; const files = await fs.readdir(path.join(process.cwd(), "config")); await Promise.all( files.map(async (file) => { if (file.endsWith(".oas.json")) { const specPath = path.join(process.cwd(), "config", file); const content = await fs.readFile(specPath, "utf-8").then(JSON.parse); const newPaths = {}; Object.entries(content.paths).forEach(([path, entry]) => { delete entry["x-zuplo-path"]; const keys = []; pathToRegexp(path, keys); let newPath = path; keys.forEach((key) => { newPath = newPath.replace(`:${key.name}`, `{${kababCase(key.name)}}`); }); Object.entries(entry).forEach(([method, methodEntry]) => { if (entry[method].parameters) { entry[method].parameters.forEach((param) => { if (param.in === "path") { param.name = kababCase(param.name); } }); } }); newPaths[newPath] = entry; }); content.paths = newPaths; const json = JSON.stringify(content, null, 2); const output = prettier.format(json, { parser: "json" }); await fs.writeFile(specPath, output, "utf-8"); } }), ); function kababCase(str) { return kabab(str).replaceAll("-u-r-l", "-url").replaceAll("-a-p-i", "-api"); }
Edit this page
Last modified on March 27, 2026
OpenAPI Server URLsOpenAPI Extension Data
Javascript