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 - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+6
.travis.yml
language: node_js
node_js:
- "6"
- "5"
- "4"
- "4.3.2"

Sorry, the diff of this file is not supported yet

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

@@ -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()
})
})