{"_id":"openapi-server-url-templating","_rev":"3-2b88c4296d88d9ef605d9f016ec6ad35","name":"openapi-server-url-templating","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"openapi-server-url-templating","version":"1.0.0","keywords":["openapi","server","url","templating","parser","validator","substitution"],"author":{"name":"Vladimír Gorej","email":"vladimir.gorej@gmail.com"},"license":"Apache-2.0","_id":"openapi-server-url-templating@1.0.0","maintainers":[{"name":"char0n","email":"vladimir.gorej@gmail.com"}],"homepage":"https://github.com/char0n/openapi-server-url-templating#readme","bugs":{"url":"https://github.com/char0n/openapi-server-url-templating/issues"},"dist":{"shasum":"8ecbdfccab8df28d372afa5ed8636399638bf7e9","tarball":"https://registry.npmjs.org/openapi-server-url-templating/-/openapi-server-url-templating-1.0.0.tgz","fileCount":25,"integrity":"sha512-hJ3sCVx7XyYATfRqBfUY+dE+DSM/tsqZ83xtcyHhNqtDiN2Il/uedCzBaE9re3gLRkC4I0GrCI84aaQHboNMCw==","signatures":[{"sig":"MEYCIQD8VwvsSrs7xFc5D5Vl8g7ms+hHBX7vVHdCu4JwL7mFagIhAJev5KxhpQS/zmwT2tGQ+iboSL7nRvLhcJm3m0azuFMA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":101715},"main":"./cjs/index.cjs","type":"module","types":"./types/index.d.ts","engines":{"node":">=12.20.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./es/index.mjs","require":"./cjs/index.cjs"},"./package.json":"./package.json","./server-variables.bnf":"./src/server-url-templating.bnf"},"gitHead":"da1af11ab4ae85a0691eeed553bcb9c140832042","imports":{"#apg-lite":{"import":"apg-lite","default":"apg-lite","require":"./cjs/apg-lite.cjs"}},"scripts":{"test":"mocha","build":"npm run grammar:compile && npm run build:es && npm run build:cjs && npm run build:cjs:apg-lite","build:es":"cross-env BABEL_ENV=es babel src --out-dir es --extensions '.js' --out-file-extension '.mjs'","build:cjs":"cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.js' --out-file-extension '.cjs'","prepublishOnly":"npm run build","grammar:compile":"./node_modules/apg-js/bin/apg.sh --lite --in=./src/server-url-templating.bnf --out=./src/server-url-templating.js && cd ./src","build:cjs:apg-lite":"cross-env BABEL_ENV=cjs babel node_modules/apg-lite/lib/parser.js --out-file ./cjs/apg-lite.cjs"},"_npmUser":{"name":"char0n","email":"vladimir.gorej@gmail.com"},"repository":{"url":"git+https://github.com/char0n/openapi-server-url-templating.git","type":"git"},"_npmVersion":"10.1.0","description":"OpenAPI Server URL templating parser, validator and substitution mechanism.","directories":{},"_nodeVersion":"20.8.1","dependencies":{"apg-lite":"^1.0.3"},"_hasShrinkwrap":false,"devDependencies":{"chai":"=5.1.1","husky":"=9.0.11","mocha":"=10.4.0","apg-js":"^4.4.0","prettier":"^3.3.1","cross-env":"^7.0.3","@babel/cli":"=7.24.7","@babel/core":"=7.24.7","@commitlint/cli":"=19.3.0","@babel/preset-env":"=7.24.7","@commitlint/config-conventional":"=19.2.2"},"_npmOperationalInternal":{"tmp":"tmp/openapi-server-url-templating_1.0.0_1717658656926_0.7499025341704366","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"openapi-server-url-templating","version":"1.1.0","keywords":["openapi","server","url","templating","parser","validator","substitution"],"author":{"name":"Vladimír Gorej","email":"vladimir.gorej@gmail.com"},"license":"Apache-2.0","_id":"openapi-server-url-templating@1.1.0","maintainers":[{"name":"char0n","email":"vladimir.gorej@gmail.com"}],"homepage":"https://github.com/swaggerexpert/openapi-server-url-templating#readme","bugs":{"url":"https://github.com/swaggerexpert/openapi-server-url-templating/issues"},"dist":{"shasum":"cae9c36d12feeec6af158a6c42e46205db125be6","tarball":"https://registry.npmjs.org/openapi-server-url-templating/-/openapi-server-url-templating-1.1.0.tgz","fileCount":25,"integrity":"sha512-dtyTFKx2xVcO0W8JKaluXIHC9l/MLjHeflBaWjiWNMCHp/TBs9dEjQDbj/VFlHR4omFOKjjmqm1pW1aCAhmPBg==","signatures":[{"sig":"MEQCIHcTtaYeXzYVVQuYzhuSeKyR679i/YLwsqFdGW2NTsTaAiB/Y4xpI8F4mmNod+Sluypibdzl5AKLqRZHX+/+evD5AA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":101707},"main":"./cjs/index.cjs","type":"module","types":"./types/index.d.ts","engines":{"node":">=12.20.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./es/index.mjs","require":"./cjs/index.cjs"},"./package.json":"./package.json","./server-variables.bnf":"./src/server-url-templating.bnf"},"gitHead":"9595332862c2328331d43f151b17e21cbf36f6f1","scripts":{"test":"mocha","build":"npm run grammar:compile && npm run build:es && npm run build:cjs && npm run build:cjs:apg-lite","build:es":"cross-env BABEL_ENV=es babel src --out-dir es --extensions '.js' --out-file-extension '.mjs'","build:cjs":"cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.js' --out-file-extension '.cjs'","prepublishOnly":"npm run build","grammar:compile":"./node_modules/apg-js/bin/apg.sh --lite --in=./src/server-url-templating.bnf --out=./src/server-url-templating.js && cd ./src","build:cjs:apg-lite":"cross-env BABEL_ENV=cjs babel node_modules/apg-lite/lib/parser.js --out-file ./cjs/apg-lite.cjs"},"_npmUser":{"name":"char0n","email":"vladimir.gorej@gmail.com"},"repository":{"url":"git+https://github.com/swaggerexpert/openapi-server-url-templating.git","type":"git"},"_npmVersion":"10.5.2","description":"OpenAPI Server URL templating parser, validator and substitution mechanism.","directories":{},"_nodeVersion":"20.13.1","dependencies":{"apg-lite":"^1.0.3"},"_hasShrinkwrap":false,"devDependencies":{"chai":"=5.1.1","husky":"=9.0.11","mocha":"=10.4.0","apg-js":"^4.4.0","prettier":"^3.3.1","cross-env":"^7.0.3","@babel/cli":"=7.24.7","@babel/core":"=7.24.7","@commitlint/cli":"=19.3.0","@babel/preset-env":"=7.24.7","babel-plugin-module-resolver":"^5.0.2","@commitlint/config-conventional":"=19.2.2"},"_npmOperationalInternal":{"tmp":"tmp/openapi-server-url-templating_1.1.0_1718395024735_0.8313911078702796","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"openapi-server-url-templating","version":"1.2.0","keywords":["openapi","server","url","templating","parser","validator","substitution"],"author":{"name":"Vladimír Gorej","email":"vladimir.gorej@gmail.com"},"license":"Apache-2.0","_id":"openapi-server-url-templating@1.2.0","maintainers":[{"name":"char0n","email":"vladimir.gorej@gmail.com"}],"homepage":"https://github.com/swaggerexpert/openapi-server-url-templating#readme","bugs":{"url":"https://github.com/swaggerexpert/openapi-server-url-templating/issues"},"dist":{"shasum":"16971b09f0fdda3f7a64fb0afc6fa651799182a2","tarball":"https://registry.npmjs.org/openapi-server-url-templating/-/openapi-server-url-templating-1.2.0.tgz","fileCount":25,"integrity":"sha512-6FVJ1SDWO6JeW9Qk5jrPRyeipYTwHJWZgTPydq+aG1CcFwa6xBB26lhIM5ncpqcDf1Owk2REtPCKgfsk2NUGKg==","signatures":[{"sig":"MEUCICotc1EhDJCGSgxrYPZU6S2zv8C1ddmI40LrfH4hDl/rAiEA+hxMhQREKoomNFZS0sp0HUHWFtjATiHmJNLms9G0uKE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":103219},"main":"./cjs/index.cjs","type":"module","types":"./types/index.d.ts","watch":{"test":"{src,test}/*.js"},"engines":{"node":">=12.20.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./es/index.mjs","require":"./cjs/index.cjs"},"./package.json":"./package.json","./server-variables.bnf":"./src/server-url-templating.bnf"},"gitHead":"a35792ab757449b84aa4ef30ae11b896b01f839f","scripts":{"test":"mocha","build":"npm run grammar:compile && npm run build:es && npm run build:cjs && npm run build:cjs:apg-lite","watch":"npm-watch","build:es":"cross-env BABEL_ENV=es babel src --out-dir es --extensions '.js' --out-file-extension '.mjs'","build:cjs":"cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.js' --out-file-extension '.cjs'","test:watch":"npm-watch test","prepublishOnly":"npm run build","grammar:compile":"node ./scripts/apg-js.js --lite --in=./src/server-url-templating.bnf --out=./src/server-url-templating.js && cd ./src","build:cjs:apg-lite":"cross-env BABEL_ENV=cjs babel node_modules/apg-lite/lib/parser.js --out-file ./cjs/apg-lite.cjs"},"_npmUser":{"name":"char0n","email":"vladimir.gorej@gmail.com"},"repository":{"url":"git+https://github.com/swaggerexpert/openapi-server-url-templating.git","type":"git"},"_npmVersion":"10.8.2","description":"OpenAPI Server URL templating parser, validator and substitution mechanism.","directories":{},"_nodeVersion":"20.18.0","dependencies":{"apg-lite":"^1.0.4"},"_hasShrinkwrap":false,"devDependencies":{"chai":"=5.1.2","husky":"=9.1.7","mocha":"=11.0.1","apg-js":"^4.4.0","prettier":"^3.3.1","cross-env":"^7.0.3","npm-watch":"^0.13.0","@babel/cli":"=7.26.4","@babel/core":"=7.26.0","@commitlint/cli":"=19.6.0","@babel/preset-env":"=7.26.0","babel-plugin-module-resolver":"^5.0.2","@commitlint/config-conventional":"=19.6.0"},"_npmOperationalInternal":{"tmp":"tmp/openapi-server-url-templating_1.2.0_1734207853560_0.26193263398913325","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"openapi-server-url-templating","version":"1.3.0","description":"OpenAPI Server URL templating parser, validator and substitution mechanism.","main":"./cjs/index.cjs","types":"./types/index.d.ts","exports":{".":{"types":"./types/index.d.ts","import":"./es/index.mjs","require":"./cjs/index.cjs"},"./package.json":"./package.json","./server-variables.bnf":"./src/server-url-templating.bnf"},"watch":{"test":"{src,test}/*.js"},"scripts":{"prepublishOnly":"npm run build","grammar:compile":"node ./scripts/apg-js.js --lite --in=./src/server-url-templating.bnf --out=./src/server-url-templating.js && cd ./src","build":"npm run grammar:compile && npm run build:es && npm run build:cjs && npm run build:cjs:apg-lite","build:es":"cross-env BABEL_ENV=es babel src --out-dir es --extensions '.js' --out-file-extension '.mjs'","build:cjs":"cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.js' --out-file-extension '.cjs'","build:cjs:apg-lite":"cross-env BABEL_ENV=cjs babel node_modules/apg-lite/lib/parser.js --out-file ./cjs/apg-lite.cjs","test":"mocha","test:watch":"npm-watch test","watch":"npm-watch"},"engines":{"node":">=12.20.0"},"type":"module","repository":{"type":"git","url":"git+https://github.com/swaggerexpert/openapi-server-url-templating.git"},"keywords":["openapi","server","url","templating","parser","validator","substitution"],"author":{"name":"Vladimír Gorej","email":"vladimir.gorej@gmail.com"},"license":"Apache-2.0","bugs":{"url":"https://github.com/swaggerexpert/openapi-server-url-templating/issues"},"homepage":"https://github.com/swaggerexpert/openapi-server-url-templating#readme","dependencies":{"apg-lite":"^1.0.4"},"devDependencies":{"@babel/cli":"=7.26.4","@babel/core":"=7.26.0","@babel/preset-env":"=7.26.0","@commitlint/cli":"=19.6.1","@commitlint/config-conventional":"=19.6.0","apg-js":"^4.4.0","babel-plugin-module-resolver":"^5.0.2","chai":"=5.1.2","cross-env":"^7.0.3","husky":"=9.1.7","mocha":"=11.0.1","npm-watch":"^0.13.0","prettier":"^3.3.1"},"_id":"openapi-server-url-templating@1.3.0","gitHead":"f9df166ecb0e676cd0eee9b9ad22c64181bf106f","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-DPlCms3KKEbjVQb0spV6Awfn6UWNheuG/+folQPzh/wUaKwuqvj8zt5gagD7qoyxtE03cIiKPgLFS3Q8Bz00uQ==","shasum":"80bc6ea5209a3c4fe9d359673ba51635676e2503","tarball":"https://registry.npmjs.org/openapi-server-url-templating/-/openapi-server-url-templating-1.3.0.tgz","fileCount":25,"unpackedSize":98224,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICuzUTkZQcknfUc81XPoI9NYgNbtLtbWzK/Aa4reg69+AiEAqFsxm4ZyVzTM8h1u+LASyLa7FUJU9uleqZNsYbFjUkA="}]},"_npmUser":{"name":"char0n","email":"vladimir.gorej@gmail.com"},"directories":{},"maintainers":[{"name":"char0n","email":"vladimir.gorej@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/openapi-server-url-templating_1.3.0_1735393172467_0.8886315901447022"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-06T07:24:16.925Z","modified":"2024-12-28T13:39:32.895Z","1.0.0":"2024-06-06T07:24:17.079Z","1.1.0":"2024-06-14T19:57:04.918Z","1.2.0":"2024-12-14T20:24:13.729Z","1.3.0":"2024-12-28T13:39:32.708Z"},"bugs":{"url":"https://github.com/swaggerexpert/openapi-server-url-templating/issues"},"author":{"name":"Vladimír Gorej","email":"vladimir.gorej@gmail.com"},"license":"Apache-2.0","homepage":"https://github.com/swaggerexpert/openapi-server-url-templating#readme","keywords":["openapi","server","url","templating","parser","validator","substitution"],"repository":{"type":"git","url":"git+https://github.com/swaggerexpert/openapi-server-url-templating.git"},"description":"OpenAPI Server URL templating parser, validator and substitution mechanism.","maintainers":[{"name":"char0n","email":"vladimir.gorej@gmail.com"}],"readme":"# openapi-server-url-templating\n\n[![npmversion](https://badge.fury.io/js/openapi-server-url-templating.svg)](https://www.npmjs.com/package/openapi-server-url-templating)\n[![npm](https://img.shields.io/npm/dm/openapi-server-url-templating.svg)](https://www.npmjs.com/package/openapi-server-url-templating)\n[![Test workflow](https://github.com/swaggerexpert/openapi-server-url-templating/actions/workflows/test.yml/badge.svg)](https://github.com/swaggerexpert/openapi-server-url-templating/actions)\n[![Dependabot enabled](https://img.shields.io/badge/Dependabot-enabled-blue.svg)](https://dependabot.com/)\n[![try on RunKit](https://img.shields.io/badge/try%20on-RunKit-brightgreen.svg?style=flat)](https://npm.runkit.com/openapi-server-url-templating)\n[![Tidelift](https://tidelift.com/badges/package/npm/openapi-server-url-templating)](https://tidelift.com/subscription/pkg/npm-openapi-server-url-templating?utm_source=npm-openapi-server-url-templating&utm_medium=referral&utm_campaign=readme)\n\n[Server URL Templating](https://spec.openapis.org/oas/v3.1.1.html#server-object) supports [Server Variables](https://spec.openapis.org/oas/v3.1.1.html#server-variable-object). Variable substitutions will be made when a variable is named in `{`brackets`}`.\nThis mechanism is used by [Server Object](https://spec.openapis.org/oas/v3.1.1.html#server-object)\nof [OpenAPI specification](https://spec.openapis.org/).\n\n`openapi-server-url-templating` is a **parser**, **validator** and **substitution mechanism** for OpenAPI Server URL Templating,\nwhich played a [foundational role](https://github.com/OAI/OpenAPI-Specification/pull/4264) in defining the official ANBF grammar for Server URL Templating.\n\nIt supports Server Object URL Templating defined in following OpenAPI specification versions:\n\n- [OpenAPI 3.0.0](https://spec.openapis.org/oas/v3.0.0.html)\n- [OpenAPI 3.0.1](https://spec.openapis.org/oas/v3.0.1.html)\n- [OpenAPI 3.0.2](https://spec.openapis.org/oas/v3.0.2.html)\n- [OpenAPI 3.0.3](https://spec.openapis.org/oas/v3.0.3.html)\n- [OpenAPI 3.0.4](https://spec.openapis.org/oas/v3.0.4.html)\n- [OpenAPI 3.1.0](https://spec.openapis.org/oas/v3.1.0.html)\n- [OpenAPI 3.1.1](https://spec.openapis.org/oas/v3.1.1.html)\n\n<table>\n  <tr>\n    <td align=\"right\" valign=\"middle\">\n        <img src=\"https://cdn2.hubspot.net/hubfs/4008838/website/logos/logos_for_download/Tidelift_primary-shorthand-logo.png\" alt=\"Tidelift\" width=\"60\" />\n      </td>\n      <td valign=\"middle\">\n        <a href=\"https://tidelift.com/subscription/pkg/npm-openapi-server-url-templating?utm_source=npm-openapi-server-url-templating&utm_medium=referral&utm_campaign=readme\">\n            Get professionally supported openapi-server-url-templating with Tidelift Subscription.\n        </a>\n      </td>\n  </tr>\n</table>\n\n## Table of Contents\n\n- [Getting started](#getting-started)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Parsing](#parsing)\n    - [Validation](#validation)\n    - [Substitution](#substitution)\n    - [Grammar](#grammar)\n- [More about OpenAPI Server URL Templating](#more-about-openapi-server-url-templating)\n- [License](#license)\n\n## Getting started\n\n### Installation\n\nYou can install `openapi-server-url-templating` using `npm`:\n\n```sh\n $ npm install openapi-server-url-templating\n```\n\n### Usage\n\n`openapi-server-url-templating` currently supports **parsing**, **validation** and **substitution**.\nBoth parser and validator are based on a superset of [ABNF](https://www.rfc-editor.org/rfc/rfc5234) ([SABNF](https://github.com/ldthomas/apg-js2/blob/master/SABNF.md))\nand use [apg-lite](https://github.com/ldthomas/apg-lite) parser generator.\n\n#### Parsing\n\nParsing a Server URL Templating is as simple as importing the **parse** function\nand calling it.\n\n```js\nimport { parse } from 'openapi-server-url-templating';\n\nconst parseResult = parse('https://{username}.gigantic-server.com:{port}/{basePath}');\nparseResult.result.success; // => true\n```\n\n**parseResult** variable has the following shape:\n\n```\n{\n  result: {\n    success: true,\n    state: 101,\n    stateName: 'MATCH',\n    length: 56,\n    matched: 56,\n    maxMatched: 56,\n    maxTreeDepth: 12,\n    nodeHits: 758\n  },\n  ast: fnast {\n    callbacks: [\n      'server-url-template': [Function: serverUrlTemplate],\n      'server-variable': [Function: serverVariable],\n      'server-variable-name': [Function: serverVariableName],\n      literals: [Function: literals]\n    ],\n    init: [Function (anonymous)],\n    ruleDefined: [Function (anonymous)],\n    udtDefined: [Function (anonymous)],\n    down: [Function (anonymous)],\n    up: [Function (anonymous)],\n    translate: [Function (anonymous)],\n    setLength: [Function (anonymous)],\n    getLength: [Function (anonymous)],\n    toXml: [Function (anonymous)]\n  }\n}\n```\n\n###### Interpreting AST as list of entries\n\n```js\nimport { parse } from 'openapi-server-url-templating';\n\nconst parseResult = parse('https://{username}.gigantic-server.com:{port}/{basePath}');\nconst parts = [];\n\nparseResult.ast.translate(parts);\n```\n\nAfter running the above code, **parts** variable has the following shape:\n\n```js\n[\n  [\n    'server-url-template',\n    'https://{username}.gigantic-server.com:{port}/{basePath}'\n  ],\n  [ 'literals', 'https://' ],\n  [ 'server-variable', '{username}' ],\n  [ 'server-variable-name', 'username' ],\n  [ 'literals', '.gigantic-server.com:' ],\n  [ 'server-variable', '{port}' ],\n  [ 'server-variable-name', 'port' ],\n  [ 'literals', '/' ],\n  [ 'server-variable', '{basePath}' ],\n  [ 'server-variable-name', 'basePath' ]\n]\n```\n\n###### Interpreting AST as XML\n\n```js\nimport { parse } from 'openapi-server-url-templating';\n\nconst parseResult = parse('https://{username}.gigantic-server.com:{port}/{basePath}');\nconst xml = parseResult.ast.toXml();\n```\n\nAfter running the above code, **xml** variable has the following content:\n\n```xml\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root nodes=\"10\" characters=\"56\">\n  <!-- input string -->\n  https://{username}.gigantic-server.com:{port}/{basePath}\n  <node name=\"server-url-template\" index=\"0\" length=\"56\">\n    https://{username}.gigantic-server.com:{port}/{basePath}\n    <node name=\"literals\" index=\"0\" length=\"8\">\n      https://\n    </node><!-- name=\"literals\" -->\n    <node name=\"server-variable\" index=\"8\" length=\"10\">\n      {username}\n      <node name=\"server-variable-name\" index=\"9\" length=\"8\">\n        username\n      </node><!-- name=\"server-variable-name\" -->\n    </node><!-- name=\"server-variable\" -->\n    <node name=\"literals\" index=\"18\" length=\"21\">\n      .gigantic-server.com:\n    </node><!-- name=\"literals\" -->\n    <node name=\"server-variable\" index=\"39\" length=\"6\">\n      {port}\n      <node name=\"server-variable-name\" index=\"40\" length=\"4\">\n        port\n      </node><!-- name=\"server-variable-name\" -->\n    </node><!-- name=\"server-variable\" -->\n    <node name=\"literals\" index=\"45\" length=\"1\">\n      /\n    </node><!-- name=\"literals\" -->\n    <node name=\"server-variable\" index=\"46\" length=\"10\">\n      {basePath}\n      <node name=\"server-variable-name\" index=\"47\" length=\"8\">\n        basePath\n      </node><!-- name=\"server-variable-name\" -->\n    </node><!-- name=\"server-variable\" -->\n  </node><!-- name=\"server-url-template\" -->\n</root>\n```\n\n> NOTE: AST can also be traversed in classical way using [depth first traversal](https://www.tutorialspoint.com/data_structures_algorithms/depth_first_traversal.htm). For more information about this option please refer to [apg-js](https://github.com/ldthomas/apg-js) and [apg-js-examples](https://github.com/ldthomas/apg-js-examples).\n\n#### Validation\n\nValidating a Server URL Templating is as simple as importing the **test** function and calling it.\n\n\n```js\nimport { test } from 'openapi-server-url-templating';\n\ntest('https://{username}.gigantic-server.com:{port}/{basePath}'); // => true\ntest('https://gigantic-server.com/base-path'); // => true\ntest('https://gigantic-server.com/base-path', { strict: true }); // => false (doesn't contain any server-variable)\n```\n\n#### Substitution\n\nPerforming Server URL template substitution is as simple as importing the **substitute** function and calling it.\n\n```js\nimport { substitute } from 'openapi-server-url-templating';\n\nsubtitute('https://{username}.gigantic-server.com', { username: 'char0n' }); // => \"https://char0n.gigantic-server.com\"\n```\n\nSubstituted Server URL Templating is automatically encoded using [encodeURIComponent](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) function.\nIt is possible to provide a custom encoder.\n\n```js\nimport { substitute } from 'openapi-server-url-templating';\n\nsubstitute('https://{username}.gigantic-server.com', { username: '/?#' }, {\n  encoder: (serverVariable) => serverVariable, // no encoding\n}); // => \"https:///?#.gigantic-server.com\"\n```\n\n#### Grammar\n\nNew grammar instance can be created in following way:\n\n```js\nimport { Grammar } from 'openapi-server-url-templating';\n\nconst grammar = new Grammar();\n```\n\nTo obtain original ABNF (SABNF) grammar as a string:\n\n```js\nimport { Grammar } from 'openapi-server-url-templating';\n\nconst grammar = new Grammar();\n\ngrammar.toString();\n// or\nString(grammar);\n```\n\n## More about OpenAPI Server URL Templating\n\nThe Server URL Templating is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax\n\n```abnf\n; OpenAPI Server URL templating ABNF syntax\nserver-url-template    = 1*( literals / server-variable ) ; variant of https://www.rfc-editor.org/rfc/rfc6570#section-2\nserver-variable        = \"{\" server-variable-name \"}\"\nserver-variable-name   = 1*( %x00-7A / %x7C / %x7E-10FFFF ) ; every UTF8 character except { and } (from OpenAPI)\n\n; https://www.rfc-editor.org/rfc/rfc6570#section-2.1\n; https://www.rfc-editor.org/errata/eid6937\nliterals               = 1*( %x21 / %x23-24 / %x26-3B / %x3D / %x3F-5B\n                       / %x5D / %x5F / %x61-7A / %x7E / ucschar / iprivate\n                       / pct-encoded)\n                            ; any Unicode character except: CTL, SP,\n                            ;  DQUOTE, \"%\" (aside from pct-encoded),\n                            ;  \"<\", \">\", \"\\\", \"^\", \"`\", \"{\", \"|\", \"}\"\n\n; https://www.rfc-editor.org/rfc/rfc6570#section-1.5\nDIGIT          =  %x30-39             ; 0-9\nHEXDIG         =  DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\" ; case-insensitive\n\npct-encoded    =  \"%\" HEXDIG HEXDIG\n\nucschar        =  %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF\n               /  %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD\n               /  %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD\n               /  %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD\n               /  %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD\n               /  %xD0000-DFFFD / %xE1000-EFFFD\n\niprivate       =  %xE000-F8FF / %xF0000-FFFFD / %x100000-10FFFD\n```\n\n## License\n\n`openapi-server-url-templating` is licensed under [Apache 2.0 license](https://github.com/swaggerexpert/openapi-server-url-templating/blob/main/LICENSE).\n`openapi-server-url-templating` comes with an explicit [NOTICE](https://github.com/swaggerexpert/openapi-server-url-templating/blob/main/NOTICE) file\ncontaining additional legal notices and information.\n","readmeFilename":"README.md"}