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-methods

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-utils-path-methods

Get openapi path methods

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

openapi-utils-path-methods

npm version Build Status JavaScript Style Guide

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:

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

Keywords

openapi

FAQs

Package last updated on 11 Jan 2017

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