Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orangewise/openapi-utils-path-for-uri
Get an openapi path for an URI
https://github.com/orangewise/openapi-utils-path-for-uri
Last synced: 8 days ago
JSON representation
Get an openapi path for an URI
- Host: GitHub
- URL: https://github.com/orangewise/openapi-utils-path-for-uri
- Owner: orangewise
- Created: 2016-11-06T09:01:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-24T11:25:55.000Z (over 6 years ago)
- Last Synced: 2024-09-15T21:59:05.661Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# openapi-utils-path-for-uri
[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)Get an openApi path for an URI.
# Installation
```
npm install --save openapi-utils-path-for-uri
```# Usage
Given the following openApi definition:
```
{
"paths": {
"/animals/cats": {
"get": { }
},
"/animals/{species}/cats": {
"get": { }
},
"/animals/{species}/dogs": {
"get": { }
},
"/animals/{species}/dogs/{breed}": {
"get": { }
}
}
}
```You can retrieve the paths like this:
```javascript
var api = require('./your-openapi.json')
var openApiUtils = require('openapi-utils-path-for-uri')var openApiPath1 = openApiUtils.pathForUri(api, '/animals/mammal/cats')
console.log(openApiPath1)
/*
/animals/{species}/cats
*/var openApiPath2 = openApiUtils.pathForUri(api, '/animals/mammal/dogs/terrier')
console.log(openApiPath2)
/*
/animals/{species}/dogs/{breed}
*/var openApiPath3 = openApiUtils.pathForUri(api, '/animals/cats')
console.log(openApiPath3)
/*
/animals/cats
*/```
[npm-badge]: https://badge.fury.io/js/openapi-utils-path-for-uri.svg
[npm-url]: https://badge.fury.io/js/openapi-utils-path-for-uri
[travis-badge]: https://travis-ci.org/orangewise/openapi-utils-path-for-uri.svg?branch=master
[travis-url]: https://travis-ci.org/orangewise/openapi-utils-path-for-uri