{"library":"openapi-path-templating","title":"OpenAPI Path Templating Utilities","description":"openapi-path-templating is a JavaScript/TypeScript library providing comprehensive tools for working with OpenAPI Path Templating expressions. It acts as a parser, validator, resolver, matcher, and normalizer for URL paths defined using OpenAPI's curly brace `{}` syntax for path parameters. The current stable version is 2.2.1, with a relatively active release cadence addressing bug fixes and feature enhancements, as seen in recent updates in late 2024 and early 2025. A key differentiator is its foundational role in defining the official ABNF grammar for OpenAPI Path Templating, ensuring high fidelity with the specification across OpenAPI versions 2.0, 3.0.x, and 3.1.x. It leverages ABNF (Augmented Backus–Naur Form) based parsers for robust and specification-compliant operations.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install openapi-path-templating"],"cli":null},"imports":["import { parse } from 'openapi-path-templating';","import { validate } from 'openapi-path-templating';","import { match } from 'openapi-path-templating';","import { normalize } from 'openapi-path-templating';","import { isIdentical } from 'openapi-path-templating';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parse, validate, resolve, match, normalize, isIdentical } from 'openapi-path-templating';\n\nconst openApiPath = '/users/{userId}/posts/{postId}';\nconst concretePath = '/users/123/posts/abc';\nconst otherConcretePath = '/users/456/posts/xyz';\nconst malformedPath = '/users/{userId/posts';\n\nconsole.log('--- Parsing ---');\nconst parsedPath = parse(openApiPath);\nconsole.log('Parsed path:', JSON.stringify(parsedPath, null, 2));\n\nconsole.log('\\n--- Validation ---');\nconst isValid = validate(openApiPath);\nconsole.log(`Is '${openApiPath}' valid?`, isValid); // true\nconst isMalformedValid = validate(malformedPath);\nconsole.log(`Is '${malformedPath}' valid?`, isMalformedValid); // false\n\nconsole.log('\\n--- Resolution ---');\nconst resolvedPath = resolve(openApiPath, { userId: '456', postId: 'def' });\nconsole.log(`Resolved path:`, resolvedPath); // /users/456/posts/def\n\nconsole.log('\\n--- Matching ---');\nconst matchedParams = match(openApiPath, concretePath);\nconsole.log(`Matched parameters for '${concretePath}':`, matchedParams); // { userId: '123', postId: 'abc' }\nconst noMatch = match(openApiPath, '/products/1');\nconsole.log(`Matched parameters for '/products/1':`, noMatch); // null\n\nconsole.log('\\n--- Normalization ---');\nconst normalizedPath = normalize('/users/./profile/../settings');\nconsole.log(`Normalized path:`, normalizedPath); // /users/settings\n\nconsole.log('\\n--- Identity Check ---');\nconst path1 = '/pets/{petId}';\nconst path2 = '/pets/{id}';\nconst path3 = '/pets/{petId}';\nconsole.log(`Is '${path1}' identical to '${path2}'?`, isIdentical(path1, path2)); // false (different parameter names)\nconsole.log(`Is '${path1}' identical to '${path3}'?`, isIdentical(path1, path3)); // true","lang":"typescript","description":"Demonstrates parsing, validating, resolving, matching, normalizing, and identity checking OpenAPI path templates against concrete URLs and parameter objects.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}