diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..265a9fc --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: vinitshahdeo +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: vinitshahdeo +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..57987fc --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,26 @@ +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 15.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.npmignore b/.npmignore index 84c2f26..3af58f7 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,4 @@ test/ -definitions/ \ No newline at end of file +definitions/ +.github/ +assets/ diff --git a/README.md b/README.md index 5a6542c..348e7bd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ # OpenAPI URL Resolver -`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 specification](https://swagger.io/specification/) and need to extract server information to make API calls. +![https://github.com/vinitshahdeo/openapi-url-resolver/actions/workflows/node.js.yml](https://github.com/vinitshahdeo/openapi-url-resolver/actions/workflows/node.js.yml/badge.svg) + + +**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. ## πŸ“¦ Installation @@ -14,12 +17,11 @@ npm install openapi-url-resolver ## πŸ’» Usage -To use `openapi-url-resolver`, you need to pass an OpenAPI 3.x specification object to the resolve() function. This function will return an array of resolved server URLs: +To 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: ```javascript -const openapiUrlResolver = require('./src') +const openapiUrlResolver = require('openapi-url-resolver') -// add complete spec const spec = { openapi: '3.0.0', servers: [ @@ -74,7 +76,7 @@ console.log(serverUrls) ``` -## Testing +## πŸ§ͺ Testing You can test using the below command or write your own tests using the OpenAPI specifications [examples](./definitions/). @@ -82,30 +84,29 @@ You can test using the below command or write your own tests using the OpenAPI s npm test ``` -## Limitations +## 🚫 Limitations -The below are the known limitations, and they are not handled to keep it a lightweight and focused module to just extract the server information. +The 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). -- It does not validate the OpenAPI definition. You can use for validating the OpenAPI definition. -- It only works with OpenAPI specification object(JSON format). - - Use js-yml to convert yml to json - - Use postman-converter for Postman collection to OpenAPI json +- 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. +- It only works with JSON format. + - Use [yaml-to-json-schema](https://www.npmjs.com/package/yaml-to-json-schema) to convert YAML to JSON. + - Use [postman-to-openapi](https://www.npmjs.com/package/postman-to-openapi) to Postman collection to OpenAPI 3.x ## 🀝 Contributing -Contributions to `openapi-url-resolver` are most welcome! If you find a bug or want to suggest a new feature, please open an issue on the GitHub repository. If you want to contribute code, please fork the repository, make your changes, and submit a pull request. Your contributions and feedback are most welcome! +**Contributions to `openapi-url-resolver` are most welcome!** -## ❀️ Support +If 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! -If you find this package useful, please consider: +## πŸ“ License -- Following me on Twitter for updates and package releases. -- Starring this repository on GitHub to show your appreciation. -- Sponsoring me on GitHub to support ongoing development. -- Buying me a coffee via PayPal or Ko-fi to help me stay fueled and focused. +[openapi-url-resolver](https://github.com/vinitshahdeo/openapi-url-resolver) is released under the [MIT License](./LICENSE). -Thank you for your support! +## ❀️ Support -## πŸ“ License +If you find this package useful, please consider [starring this repository]() on GitHub to show your appreciation. You can stay connected with me on Twitterβ€”[@vinit_shahdeo](https://twitter.com/Vinit_Shahdeo). + +Buy Me A Coffee -`openapi-url-resolver` is released under the MIT License. +Thank you for your support! πŸ™