0.0.9 • Published 6 years ago

openapi-utils-path-for-uri v0.0.9

Weekly downloads
53
License
ISC
Repository
github
Last release
6 years ago

openapi-utils-path-for-uri

npm version Build Status JavaScript Style Guide

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:

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
*/
0.0.9

6 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago