openapi-utils-defaults

0.0.7 • Public • Published

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"
          }
        }
      }
    }
  ]
}

Readme

Keywords

Package Sidebar

Install

npm i openapi-utils-defaults

Weekly Downloads

0

Version

0.0.7

License

ISC

Last publish

Collaborators

  • robodo