Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vinitshahdeo/openapi-url-resolver i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
vinitshahdeo committed Apr 20, 2023
2 parents 22d24ab + 510ab72 commit dd38777
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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']
26 changes: 26 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
test/
definitions/
definitions/
.github/
assets/
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: [
Expand Down Expand Up @@ -74,38 +76,37 @@ console.log(serverUrls)

```

## Testing
## 🧪 Testing

You can test using the below command or write your own tests using the OpenAPI specifications [examples](./definitions/).

```bash
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).

<a href="https://www.buymeacoffee.com/vinitshahdeo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

`openapi-url-resolver` is released under the MIT License.
Thank you for your support! 🙏

0 comments on commit dd38777

Please sign in to comment.