{"id":15091391,"url":"https://github.com/vinitshahdeo/openapi-url-resolver","last_synced_at":"2025-06-13T02:04:19.172Z","repository":{"id":153940759,"uuid":"630161086","full_name":"vinitshahdeo/openapi-url-resolver","owner":"vinitshahdeo","description":"Resolve server URLs and extract hosts from OpenAPI 3.x and Swagger specifications.","archived":false,"fork":false,"pushed_at":"2023-04-27T05:38:07.000Z","size":216,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-14T19:47:39.461Z","etag":null,"topics":["openapi","openapi-parser","openapi-server-url","openapi-specification","openapi-url-resolver","openapi3"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/openapi-url-resolver","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vinitshahdeo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"vinitshahdeo","patreon":null,"open_collective":null,"ko_fi":"vinitshahdeo","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-04-19T19:50:39.000Z","updated_at":"2025-01-21T01:56:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"42308b92-d2eb-403a-a9b8-e356263b7a1f","html_url":"https://github.com/vinitshahdeo/openapi-url-resolver","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vinitshahdeo/openapi-url-resolver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitshahdeo%2Fopenapi-url-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitshahdeo%2Fopenapi-url-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitshahdeo%2Fopenapi-url-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitshahdeo%2Fopenapi-url-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinitshahdeo","download_url":"https://codeload.github.com/vinitshahdeo/openapi-url-resolver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinitshahdeo%2Fopenapi-url-resolver/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259565540,"owners_count":22877346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openapi","openapi-parser","openapi-server-url","openapi-specification","openapi-url-resolver","openapi3"],"created_at":"2024-09-25T10:40:47.120Z","updated_at":"2025-06-13T02:04:19.161Z","avatar_url":"https://github.com/vinitshahdeo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/vinitshahdeo","https://ko-fi.com/vinitshahdeo","https://www.buymeacoffee.com/vinitshahdeo"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"./assets/openapi-url-resolver-logo.png\" height='30%' width='30%'/\u003e\n\n\u003ch1\u003eOpenAPI URL Resolver\u003c/h1\u003e\n\n\u003cp\u003e\n\u003ca href=\"https://www.npmjs.com/package/openapi-url-resolver\"\u003e\u003cimg alt=\"npm openapi-url-resolver\" src=\"https://img.shields.io/npm/v/openapi-url-resolver?label=openapi-url-resolver\u0026logo=npm\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/openapi-url-resolver\"\u003e\u003cimg alt=\"npm bundle size\" src=\"https://img.shields.io/bundlephobia/min/openapi-url-resolver?logo=npm\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/openapi-url-resolver\"\u003e\u003cimg alt=\"npm openapi-url-resolver\" src=\"https://img.shields.io/npm/dm/openapi-url-resolver?logo=npm\u0026color=yellowgreen\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/vinitshahdeo/openapi-url-resolver/actions/workflows/node.js.yml\"\u003e\u003cimg src=\"https://github.com/vinitshahdeo/openapi-url-resolver/actions/workflows/node.js.yml/badge.svg\" alt=\"GitHub Actions for OpenAPI URL Resolver\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/Vinit_Shahdeo\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/Vinit_Shahdeo?style=social\" alt=\"Twitter Follow\"\u003e\u003c/a\u003e\n\u003ca href='./LICENSE'\u003e\u003cimg alt=\"GitHub License\" src=\"https://img.shields.io/github/license/vinitshahdeo/celeb-diwali?label=License\u0026logo=github\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr/\u003e\n\n\u003c/div\u003e\n\n\n**openapi-url-resolver** is a **lightweight** NPM package that provides a simple and efficient way to resolve server URLs from OpenAPI specifications. It also removes protocols from the resolved URLs and allows you to **easily extract host information from OpenAPI definitions**. This package is ideal for developers working with APIs that conform to the [OpenAPI 3.x specification](https://swagger.io/specification/) and need to extract [server information](https://spec.openapis.org/oas/v3.1.0#server-object) to make API calls. Check out the blog post for more details—[How to resolve server URLs containing variables in OpenAPI 3.x definitions?](https://dev.to/vinitshahdeo/how-to-resolve-server-urls-containing-variables-in-openapi-3x-definitions-kaj)\n\n### Features:\n\n- 🚀 **Lightweight** module with only 965 bytes in size\n- 🎉 **Zero dependencies**, making it easy to install and use in your projects\n- 🔍 Efficient and simple way to resolve [server URLs](https://spec.openapis.org/oas/v3.1.0#server-object) from OpenAPI specifications\n\n## 📦 Installation\n\nYou can install `openapi-url-resolver` via [NPM](https://www.npmjs.com/package/openapi-url-resolver):\n\n```bash\nnpm install openapi-url-resolver\n```\n\n[![openapi-url-resolver on NPM](https://nodei.co/npm/openapi-url-resolver.png)](https://nodei.co/npm/openapi-url-resolver/)\n\n## 💻 Usage\n\nTo use `openapi-url-resolver`, you need to pass an [OpenAPI 3.x specification](https://swagger.io/specification/) object to the `resolve()` function. This function will return an array of resolved server URLs:\n\n```javascript\nconst openapiUrlResolver = require('openapi-url-resolver')\n\nconst spec = {\n  openapi: '3.0.0',\n  servers: [\n    {\n      url: 'https://{username}.gigantic-server.com:{port}/{basePath}',\n      description: 'The production API server',\n      variables: {\n        username: {\n          default: 'demo',\n          description: 'this value is assigned by the service provider, in this example `gigantic-server.com`'\n        },\n        port: {\n          enum: ['8443', '443'],\n          default: '8443'\n        },\n        basePath: {\n          default: 'v2'\n        }\n      }\n    }\n  ]\n}\n\nconst hosts = openapiUrlResolver.resolve(spec)\n\n/*\n\n[\n  'demo.gigantic-server.com:8443/v2',\n  'demo.gigantic-server.com:443/v2'\n]\n\n*/\nconsole.log(hosts)\n\n```\n\nPass `false` as second parameter to get the server URLs with protocols.\n\n```javascript\nconst serverUrls = openapiUrlResolver.resolve(spec, false)\n\n/*\n\n[\n  'https://demo.gigantic-server.com:8443/v2',\n  'https://demo.gigantic-server.com:443/v2'\n]\n\n*/\nconsole.log(serverUrls)\n\n```\n\n## 🧪 Testing\n\nYou can test using the below command or write your own tests using the OpenAPI specifications [examples](./definitions/).\n\n```bash\nnpm test\n```\n\n## 🚫 Limitations\n\nThe below are the known limitations, and they are not handled to keep it a **lightweight** and **focused** module to just extract the [server information](https://spec.openapis.org/oas/v3.1.0#server-object).\n\n- It does not validate the OpenAPI definition. You can use [openapi-schema-validator](https://www.npmjs.com/package/openapi-schema-validator) for validating the OpenAPI definition.\n- It only works with JSON format.\n  - Use [yaml-to-json-schema](https://www.npmjs.com/package/yaml-to-json-schema) to convert YAML to JSON.\n  - Use [postman-to-openapi](https://www.npmjs.com/package/postman-to-openapi) to convert Postman collection to OpenAPI 3.x\n\n## 🤝 Contributing\n\n**Contributions to `openapi-url-resolver` are most welcome!** \n\nIf you find a bug or want to suggest a new feature, please [open an issue](https://github.com/vinitshahdeo/openapi-url-resolver/issues/new) on the GitHub repository. If you want to contribute code, please [fork the repository](https://github.com/vinitshahdeo/openapi-url-resolver/fork), make your changes, and **submit a pull request**. Your contributions and feedback are most welcome!\n\n## 📝 License\n\n[openapi-url-resolver](https://www.npmjs.com/package/openapi-url-resolver) is authored by @[vinitshahdeo](https://github.com/vinitshahdeo) and released under the [MIT License](./LICENSE).\n\n## ❤️ Support\n\nIf you find this package useful, please consider [starring this repository](https://github.com/vinitshahdeo/openapi-url-resolver) on GitHub to show your appreciation. You can stay connected with me on Twitter—[@vinit_shahdeo](https://twitter.com/Vinit_Shahdeo).\n\n\u003ca href=\"https://www.buymeacoffee.com/vinitshahdeo\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"40px\" width=\"150px\" \u003e\u003c/a\u003e\n\nThank you for your support! 🙏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinitshahdeo%2Fopenapi-url-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinitshahdeo%2Fopenapi-url-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinitshahdeo%2Fopenapi-url-resolver/lists"}