openapi-utils-defaults
Advanced tools
| language: node_js | ||
| node_js: | ||
| - "6" | ||
| - "5" | ||
| - "4" | ||
| - "4.3.2" |
Sorry, the diff of this file is not supported yet
+17
| var minimist = require('minimist') | ||
| var fs = require('fs') | ||
| var join = require('path').join | ||
| function usage () { | ||
| return fs.readFileSync(join(__dirname, 'usage.txt'), 'utf8') | ||
| } | ||
| exports.parse = function () { | ||
| var options = minimist(process.argv.slice(2)) | ||
| if (!(options.t && options.s)) { | ||
| console.log(usage()) | ||
| process.exit(1) | ||
| } else { | ||
| return options | ||
| } | ||
| } |
| Usage: openapi-utils-defaults -s path-to-x-127.yaml -t path-to-api.yaml > path-to-result-api.json | ||
| Default the values of the source x-127 yaml into the target api.yaml. | ||
| The command outputs the result as json which can be piped into a new file. | ||
| { | ||
| "version": 1.0, | ||
| "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-Credentials": { | ||
| "type": "boolean", | ||
| "default": true | ||
| }, | ||
| "Access-Control-Allow-Headers": { | ||
| "type": "array", | ||
| "collectionFormat": "csv", | ||
| "default": "origin, x-requested-with, accept, x-authcode, x-authstate" | ||
| }, | ||
| "Access-Control-Allow-Methods": { | ||
| "type": "array", | ||
| "collectionFormat": "csv", | ||
| "default": "GET, PUT, POST" | ||
| }, | ||
| "Access-Control-Max-Age": { | ||
| "type": "integer", | ||
| "default": 3628800 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
| 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-Credentials: | ||
| type: boolean | ||
| default: true | ||
| Access-Control-Allow-Headers: | ||
| type: array | ||
| collectionFormat: csv | ||
| default: origin, x-requested-with, accept, x-authcode, x-authstate | ||
| Access-Control-Allow-Methods: | ||
| type: array | ||
| collectionFormat: csv | ||
| default: GET, PUT, POST, DELETE | ||
| Access-Control-Max-Age: | ||
| type: integer | ||
| default: 3628800 |
| version: 1.0 | ||
| x-a127-services: | ||
| - name: add-cors | ||
| provider: x-cors | ||
| options: | ||
| displayName: Add CORS | ||
| includeInErrorResponse: true | ||
| headers: | ||
| Access-Control-Allow-Methods: | ||
| type: array | ||
| collectionFormat: csv | ||
| # Overwrite allowed methods | ||
| default: GET, PUT, POST |
+23
-3
| { | ||
| "name": "openapi-utils-defaults", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "Defaults api parts into an openapi definition", | ||
@@ -9,2 +9,5 @@ "main": "index.js", | ||
| }, | ||
| "bin": { | ||
| "openapi-utils-defaults": "bin/openapi-utils-defaults" | ||
| }, | ||
| "author": "Ronald Luitwieler", | ||
@@ -18,4 +21,21 @@ "license": "ISC", | ||
| "json-schema-ref-parser": "^3.1.2", | ||
| "lodash.defaultsdeep": "^4.6.0" | ||
| } | ||
| "lodash.defaultsdeep": "^4.6.0", | ||
| "minimist": "^1.2.0" | ||
| }, | ||
| "directories": { | ||
| "test": "test" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/orangewise/openapi-utils-defaults.git" | ||
| }, | ||
| "keywords": [ | ||
| "openapi", | ||
| "merge", | ||
| "defaults" | ||
| ], | ||
| "bugs": { | ||
| "url": "https://github.com/orangewise/openapi-utils-defaults/issues" | ||
| }, | ||
| "homepage": "https://github.com/orangewise/openapi-utils-defaults#readme" | ||
| } |
+15
-3
@@ -5,3 +5,3 @@ var test = require('tape') | ||
| test('defaults 01', function (t) { | ||
| test('defaults 01: properties are added', function (t) { | ||
| defaults.apiDefaults( | ||
@@ -18,3 +18,3 @@ join(__dirname, 'fixtures/01target.yaml'), | ||
| test('defaults 02', function (t) { | ||
| test('defaults 02: properties are added', function (t) { | ||
| defaults.apiDefaults( | ||
@@ -31,3 +31,3 @@ join(__dirname, 'fixtures/02target.yaml'), | ||
| test('defaults 03', function (t) { | ||
| test('defaults 03: response is not overwritten', function (t) { | ||
| defaults.apiDefaults( | ||
@@ -43,1 +43,13 @@ join(__dirname, 'fixtures/03target.yaml'), | ||
| }) | ||
| test('defaults 04: overwrite a nested key (method)', function (t) { | ||
| defaults.apiDefaults( | ||
| join(__dirname, 'fixtures/04target.yaml'), | ||
| join(__dirname, 'fixtures/04source.yaml'), | ||
| function (e, r) { | ||
| t.equal(e, null, 'no errors found') | ||
| var expected = require(join(__dirname, 'fixtures/04result.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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
13758
40.7%20
53.85%284
28.51%1
-50%1
-50%3
50%5
25%+ Added
+ Added