The `openapi-server-url-templating` library provides a robust, specification-compliant mechanism for parsing, validating, and performing substitutions on server URLs as defined within the OpenAPI Specification. It comprehensively supports server URL templating features, including Server Variables, across various OpenAPI versions from 3.0.0 through 3.1.1. The current stable version is 1.3.0, released in December 2024, indicating an active development and maintenance cadence. A key differentiator is its foundational role in establishing the official ABNF grammar for Server URL Templating within the OpenAPI Specification itself, which ensures a high degree of fidelity and accuracy to the standard. The library leverages `apg-lite` for its underlying parsing and validation capabilities, offering a reliable tool for developers working with OpenAPI definitions.
npm install openapi-server-url-templatingVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing, validating, and substituting an OpenAPI server URL template using defined server variables and supplied values, including usage of default values.
Ensure your OpenAPI server URL templates strictly adhere to the OpenAPI Specification's ANBF grammar to guarantee consistent parsing and validation.
Upgrade to version 1.1.0 or newer to avoid potential module resolution problems, especially in bundlers or specific Node.js setups.
Always provide a complete `serverVariables` object that includes definitions (even with just a `default` property) for every variable expected in your URL templates.
Ensure your project is configured to correctly handle ES modules. If using TypeScript, check `tsconfig.json` `module` and `moduleResolution` settings. For JavaScript, verify your bundler's configuration or explicitly use ESM imports in a module-aware context.
Review the URL template for syntax errors, missing braces (`{`, `}`), or invalid characters according to the OpenAPI Specification's Server Object URL rules. Refer to the `parseResult` object for detailed error messages.Add a definition for `someVar` to your `serverVariables` object, even if it's just `someVar: { default: 'defaultValue' }`. All templated variables must have a corresponding entry.No dependency data recorded yet.