Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orangewise/openapi-utils-path-methods
Get openapi path methods.
https://github.com/orangewise/openapi-utils-path-methods
Last synced: 8 days ago
JSON representation
Get openapi path methods.
- Host: GitHub
- URL: https://github.com/orangewise/openapi-utils-path-methods
- Owner: orangewise
- Created: 2017-01-11T18:48:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-11T19:38:24.000Z (almost 8 years ago)
- Last Synced: 2024-09-26T13:35:38.536Z (about 2 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# openapi-utils-path-methods
[![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 openapi path methods.
# Installation
```
npm install --save openapi-utils-path-methods
```# Usage
Given the following openApi definition:
```
{
"paths": {
"/animals/cats": {
"get": { },
"post": { }
},
"/animals/{species}/cats": {
"get": { },
"put": { }
},
"/animals/{species}/dogs": {
"get": { }
},
"/animals/{species}/dogs/{breed}": {
"get": { },
"patch": { }
}
}
}
```You can retrieve the path methods like this:
```javascript
var api = require('./your-openapi.json')
var openApiUtils = require('openapi-utils-path-methods')var m = openApiUtils.methods(api, '/animals/{species}/cats')
console.log(m)
/*
['GET', 'PUT']
*/m = openApiUtils.methods(api, '/animals/{species}/dogs/{breed}')
console.log(m)
/*
['GET', 'PATCH']
*/m = openApiUtils.methods(api, '/animals/cats')
console.log(m)
/*
['GET', 'POST']
*/m = openApiUtils.methods(api, '/animals/{species}/dogs')
console.log(m)
/*
['GET']
*/```
[npm-badge]: https://badge.fury.io/js/openapi-utils-path-methods.svg
[npm-url]: https://badge.fury.io/js/openapi-utils-path-methods
[travis-badge]: https://travis-ci.org/orangewise/openapi-utils-path-methods.svg?branch=master
[travis-url]: https://travis-ci.org/orangewise/openapi-utils-path-methods