openapi-utils-defaults
Advanced tools
+105
| # openapi-utils-defaults | ||
| [![npm version][npm-badge]][npm-url] | ||
| [![Build Status][travis-badge]][travis-url] | ||
| [](http://standardjs.com/) | ||
| 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 | ||
| ```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 | ||
| ```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 | ||
| ```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" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| [npm-badge]: https://badge.fury.io/js/openapi-utils-defaults.svg | ||
| [npm-url]: https://badge.fury.io/js/openapi-utils-defaults | ||
| [travis-badge]: https://travis-ci.org/orangewise/openapi-utils-defaults.svg?branch=master | ||
| [travis-url]: https://travis-ci.org/orangewise/openapi-utils-defaults |
| { | ||
| "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" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
| 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 |
| 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 |
+1
-1
| { | ||
| "name": "openapi-utils-defaults", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "Defaults api parts into an openapi definition", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+12
-0
@@ -52,1 +52,13 @@ var test = require('tape') | ||
| }) | ||
| test('README example', function (t) { | ||
| defaults.apiDefaults( | ||
| join(__dirname, 'fixtures/READMEtarget.yaml'), | ||
| join(__dirname, 'fixtures/READMEsource.yaml'), | ||
| function (e, r) { | ||
| t.equal(e, null, 'no errors found') | ||
| var expected = require(join(__dirname, 'fixtures/READMEresult.json')) | ||
| t.deepEqual(r, expected, 'merge succeeded') | ||
| t.end() | ||
| }) | ||
| }) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
17814
29.48%24
20%327
15.14%1
-50%106
Infinity%6
20%