GitXplorerGitXplorer
o

openapi-utils-path-for-uri

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
eee05e4644ec22896a643b278ca9020ed1f99b66

0.0.9

oorangewise committed 7 years ago
Unverified
4a33289f47b2002f73a6c0501df9d7152b8ce489

update node versions

oorangewise committed 7 years ago
Unverified
bc757b81659d942935e434fdcbe7f606a9eab3fd

allow dots

oorangewise committed 7 years ago
Unverified
2166115d2d9c1c9bd5cd0a4a0f9b72b3b1be2b0d

0.0.8

oorangewise committed 8 years ago
Unverified
5addee47dab5c8f3597c0d259ef7437d75124d30

support paths on / only

oorangewise committed 8 years ago
Unverified
7b7bc84d6eb07a0545fc69527fd48fc83bd8140a

0.0.7

oorangewise committed 8 years ago

README

The README file for this repository.

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