You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

openapi-utils-path-for-uri

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-utils-path-for-uri

Get an openapi path for an URI

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
1
Created
Source

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


Keywords

openapi

FAQs

Package last updated on 24 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts