Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-sampler

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-sampler - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

39

dist/openapi-sampler.js

@@ -424,2 +424,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OpenAPISampler = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

function sample(schema, options, spec) {
console.log('LJKJKJKJKJKJK');
var opts = Object.assign({}, defaults, options);

@@ -872,2 +873,4 @@ (0, _traverse.clearCache)();

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

@@ -988,8 +991,13 @@

}, schema.oneOf[0]);
return tryInferExample(schema) || traverse(firstOneOf, options, spec, context);
return traverseOneOrAnyOf(schema, firstOneOf);
}
if (schema.anyOf && schema.anyOf.length) {
(0, _utils.popSchemaStack)(seenSchemasStack, context);
return tryInferExample(schema) || traverse(schema.anyOf[0], options, spec, context);
(0, _utils.popSchemaStack)(seenSchemasStack, context); // Make sure to pass down readOnly and writeOnly annotations from the parent
var firstAnyOf = Object.assign({
readOnly: schema.readOnly,
writeOnly: schema.writeOnly
}, schema.anyOf[0]);
return traverseOneOrAnyOf(schema, firstAnyOf);
}

@@ -1031,2 +1039,25 @@

};
function traverseOneOrAnyOf(schema, selectedSubSchema) {
var inferred = tryInferExample(schema);
if (inferred !== undefined) {
return inferred;
}
var localExample = traverse(_objectSpread(_objectSpread({}, schema), {}, {
oneOf: undefined,
anyOf: undefined
}), options, spec, context);
var subSchemaExample = traverse(selectedSubSchema, options, spec, context);
if (_typeof(localExample.value) === 'object' && _typeof(subSchemaExample.value) === 'object') {
var mergedExample = (0, _utils.mergeDeep)(localExample.value, subSchemaExample.value);
return _objectSpread(_objectSpread({}, subSchemaExample), {}, {
value: mergedExample
});
}
return subSchemaExample;
}
}

@@ -1087,3 +1118,3 @@

return objects.reduce(function (prev, obj) {
Object.keys(obj).forEach(function (key) {
Object.keys(obj || {}).forEach(function (key) {
var pVal = prev[key];

@@ -1090,0 +1121,0 @@ var oVal = obj[key];

2

package.json
{
"name": "openapi-sampler",
"version": "1.2.1",
"version": "1.2.2",
"description": "Tool for generation samples based on OpenAPI payload/response schema",

@@ -5,0 +5,0 @@ "main": "dist/openapi-sampler.js",

@@ -115,5 +115,3 @@ import { _samplers } from './openapi-sampler';

return (
tryInferExample(schema) || traverse(firstOneOf, options, spec, context)
);
return traverseOneOrAnyOf(schema, firstOneOf)
}

@@ -123,3 +121,10 @@

popSchemaStack(seenSchemasStack, context);
return tryInferExample(schema) || traverse(schema.anyOf[0], options, spec, context);
// Make sure to pass down readOnly and writeOnly annotations from the parent
const firstAnyOf = Object.assign({
readOnly: schema.readOnly,
writeOnly: schema.writeOnly
}, schema.anyOf[0]);
return traverseOneOrAnyOf(schema, firstAnyOf)
}

@@ -156,2 +161,19 @@

};
function traverseOneOrAnyOf(schema, selectedSubSchema) {
const inferred = tryInferExample(schema);
if (inferred !== undefined) {
return inferred;
}
const localExample = traverse({...schema, oneOf: undefined, anyOf: undefined }, options, spec, context);
const subSchemaExample = traverse(selectedSubSchema, options, spec, context);
if (typeof localExample.value === 'object' && typeof subSchemaExample.value === 'object') {
const mergedExample = mergeDeep(localExample.value, subSchemaExample.value);
return {...subSchemaExample, value: mergedExample };
}
return subSchemaExample;
}
}

@@ -35,3 +35,3 @@ 'use strict';

return objects.reduce((prev, obj) => {
Object.keys(obj).forEach(key => {
Object.keys(obj || {}).forEach(key => {
const pVal = prev[key];

@@ -38,0 +38,0 @@ const oVal = obj[key];

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc