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

openapi-utils-defaults

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-utils-defaults

Defaults api parts into an openapi definition

latest
Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

openapi-utils-defaults

npm version Build Status JavaScript Style Guide

Defaults api parts into an openapi definition.

Installation

npm install -g openapi-utils-defaults

Usage

Given the example files displayed below (api.yaml and x-a127.yaml), the following command

openapi-utils-defaults -s x-a127.yaml -t api.yaml > api.json

Will result in the api.json, also displayed below :)

Example api.yaml

swagger: "2.0"
info:
  version: 1.0.0
  title: openapi example
basePath: /v1
paths:
  /pets:
x-a127-services:
  - name: add-cors
    provider: x-cors
    options:
      displayName: Add CORS
      includeInErrorResponse: true
      headers:
        Access-Control-Allow-Methods:
          type: array
          collectionFormat: csv
          default: GET

Example x-a127.yaml

x-a127-services:
  - name: add-cors
    provider: x-cors
    options:
      displayName: Add CORS
      includeInErrorResponse: true
      headers:
        Access-Control-Allow-Origin:
          type: string
          default: "*"
        Access-Control-Allow-Methods:
          type: array
          collectionFormat: csv
          default: GET, PUT, POST, DELETE

Result api.json

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "openapi example"
  },
  "basePath": "/v1",
  "paths": {
    "/pets": null
  },
  "x-a127-services": [
    {
      "name": "add-cors",
      "provider": "x-cors",
      "options": {
        "displayName": "Add CORS",
        "includeInErrorResponse": true,
        "headers": {
          "Access-Control-Allow-Origin": {
            "type": "string",
            "default": "*"
          },
          "Access-Control-Allow-Methods": {
            "type": "array",
            "collectionFormat": "csv",
            "default": "GET"
          }
        }
      }
    }
  ]
}

Keywords

openapi

FAQs

Package last updated on 02 Feb 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