openapi-sampler
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -420,4 +420,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) { | ||
var spec = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : schema; | ||
function sample(schema, options, spec) { | ||
var opts = Object.assign({}, defaults, options); | ||
@@ -463,3 +462,3 @@ (0, _traverse.clearCache)(); | ||
var depth = context && context.depth || 1; | ||
var arrayLength = Math.min('maxItems' in schema ? schema.maxItems : Infinity, schema.minItems || 1); // for the sake of simplicity, we're treating `contains` in a similar way to `items` | ||
var arrayLength = Math.min(schema.maxItems != undefined ? schema.maxItems : Infinity, schema.minItems || 1); // for the sake of simplicity, we're treating `contains` in a similar way to `items` | ||
@@ -691,2 +690,6 @@ var items = schema.items || schema.contains; | ||
function idnEmailSample() { | ||
return 'пошта@укр.нет'; | ||
} | ||
function passwordSample(min, max) { | ||
@@ -770,2 +773,6 @@ var res = 'pa$$word'; | ||
function idnHostnameSample() { | ||
return 'приклад.укр'; | ||
} | ||
function uriSample() { | ||
@@ -788,3 +795,3 @@ return 'http://example.com'; | ||
function iriReferenceSample() { | ||
return '../dictionary'; | ||
return '../словник'; | ||
} | ||
@@ -810,3 +817,3 @@ | ||
'email': emailSample, | ||
'idn-email': emailSample, | ||
'idn-email': idnEmailSample, | ||
// https://tools.ietf.org/html/rfc6531#section-3.3 | ||
@@ -821,3 +828,3 @@ 'password': passwordSample, | ||
'hostname': hostnameSample, | ||
'idn-hostname': hostnameSample, | ||
'idn-hostname': idnHostnameSample, | ||
// https://tools.ietf.org/html/rfc5890#section-2.3.2.3 | ||
@@ -896,2 +903,6 @@ 'iri': iriSample, | ||
if (schema.$ref) { | ||
if (!spec) { | ||
throw new Error('Your schema contains $ref. You must provide full specification in the third parameter.'); | ||
} | ||
var ref = decodeURIComponent(schema.$ref); | ||
@@ -898,0 +909,0 @@ |
{ | ||
"name": "openapi-sampler", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tool for generation samples based on OpenAPI payload/response schema", | ||
"main": "dist/openapi-sampler.js", | ||
"module": "src/openapi-sampler.js", | ||
"types": "./src/types.d.ts", | ||
"scripts": { | ||
@@ -17,2 +18,6 @@ "test": "gulp", | ||
}, | ||
"files": [ | ||
"src/", | ||
"dist/" | ||
], | ||
"repository": { | ||
@@ -52,2 +57,3 @@ "type": "git", | ||
"del": "^5.1.0", | ||
"eslint": "^7.27.0", | ||
"glob": "^7.1.6", | ||
@@ -60,3 +66,3 @@ "gulp": "^4.0.2", | ||
"gulp-load-plugins": "^2.0.1", | ||
"gulp-mocha": "^7.0.2", | ||
"gulp-mocha": "^8.0.0", | ||
"gulp-plumber": "^1.2.1", | ||
@@ -68,3 +74,3 @@ "gulp-rename": "^1.4.0", | ||
"json-loader": "^0.5.7", | ||
"karma": "^4.4.1", | ||
"karma": "^6.3.2", | ||
"karma-babel-preprocessor": "^8.0.1", | ||
@@ -75,3 +81,3 @@ "karma-browserify": "^6.1.0", | ||
"karma-firefox-launcher": "^1.2.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha": "^2.0.1", | ||
"karma-mocha-reporter": "^2.2.5", | ||
@@ -78,0 +84,0 @@ "karma-phantomjs-launcher": "^1.0.4", |
@@ -37,2 +37,3 @@ # openapi-sampler | ||
- Support for `$ref` resolving | ||
- Has basic supports for JSON Schema draft 7 (thanks to [@P0lip](https://github.com/P0lip) from [@stoplightio](https://github.com/stoplightio) for contributing) | ||
@@ -58,3 +59,3 @@ ## Installation | ||
- **schema** (_required_) - `object` | ||
A [OpenAPI Schema Object](http://swagger.io/specification/#schemaObject) | ||
An [OpenAPI Schema Object](http://swagger.io/specification/#schemaObject) or a JSON Schema Draft 7 document. | ||
- **options** (_optional_) - `object` | ||
@@ -61,0 +62,0 @@ Available options: |
@@ -11,3 +11,3 @@ import { traverse, clearCache } from './traverse'; | ||
export function sample(schema, options, spec = schema) { | ||
export function sample(schema, options, spec) { | ||
let opts = Object.assign({}, defaults, options); | ||
@@ -14,0 +14,0 @@ clearCache(); |
@@ -5,3 +5,3 @@ import { traverse } from '../traverse'; | ||
let arrayLength = Math.min('maxItems' in schema ? schema.maxItems : Infinity, schema.minItems || 1); | ||
let arrayLength = Math.min(schema.maxItems != undefined ? schema.maxItems : Infinity, schema.minItems || 1); | ||
// for the sake of simplicity, we're treating `contains` in a similar way to `items` | ||
@@ -8,0 +8,0 @@ const items = schema.items || schema.contains; |
@@ -10,3 +10,5 @@ 'use strict'; | ||
} | ||
function idnEmailSample() { | ||
return 'пошта@укр.нет'; | ||
} | ||
function passwordSample(min, max) { | ||
@@ -63,3 +65,5 @@ let res = 'pa$$word'; | ||
} | ||
function idnHostnameSample() { | ||
return 'приклад.укр'; | ||
} | ||
function uriSample() { | ||
@@ -82,3 +86,3 @@ return 'http://example.com'; | ||
function iriReferenceSample() { | ||
return '../dictionary'; | ||
return '../словник'; | ||
} | ||
@@ -104,3 +108,3 @@ | ||
'email': emailSample, | ||
'idn-email': emailSample, // https://tools.ietf.org/html/rfc6531#section-3.3 | ||
'idn-email': idnEmailSample, // https://tools.ietf.org/html/rfc6531#section-3.3 | ||
'password': passwordSample, | ||
@@ -113,3 +117,3 @@ 'date-time': dateTimeSample, | ||
'hostname': hostnameSample, | ||
'idn-hostname': hostnameSample, // https://tools.ietf.org/html/rfc5890#section-2.3.2.3 | ||
'idn-hostname': idnHostnameSample, // https://tools.ietf.org/html/rfc5890#section-2.3.2.3 | ||
'iri': iriSample, // https://tools.ietf.org/html/rfc3987 | ||
@@ -116,0 +120,0 @@ 'iri-reference': iriReferenceSample, |
@@ -31,2 +31,5 @@ import { _samplers } from './openapi-sampler'; | ||
if (schema.$ref) { | ||
if (!spec) { | ||
throw new Error('Your schema contains $ref. You must provide full specification in the third parameter.'); | ||
} | ||
let ref = decodeURIComponent(schema.$ref); | ||
@@ -33,0 +36,0 @@ if (ref.startsWith('#')) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
84
2
56786
47
16
1413