We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In case of a schema with circular references, that is re-referenced with @apidevtools/json-schema-ref-parser for example Circularity is not supported
version: 0.5.0-rcv.33
jsf.option({ alwaysFakeOptionals: true }, undefined); const jsf = require('json-schema-faker'); const schema2 = { type: 'object', properties: { prop3: {type: 'number'}, prop4: {type: 'number'}, pointer: null }}; const schemaRoot = { type: 'object', properties: { prop1: {type: 'string'}, prop2: {type: 'string'}, pointer: schema2 } } schema2.properties.pointer = schemaRoot; const fake = jsf.generate(schemaRoot); console.log(fake);
result
const jsf = require('json-schema-faker'); const schema2 = { type: 'object', properties: { prop3: {type: 'number'}, prop4: {type: 'number'}, pointer: null }}; const schemaRoot = { type: 'object', properties: { prop1: {type: 'string'}, prop2: {type: 'string'}, pointer: schema2 } } schema2.properties.pointer = schemaRoot; const fake = jsf.generate(schemaRoot); console.log(fake);
I crashed in getRefs function I;ve test a local fix that resolves it;
function getRefs(refs, schema) { var $refs = {}; if (Array.isArray(refs)) { refs.forEach(function (_schema) { $refs[_schema.$id || _schema.id] = _schema; }); } else { $refs = refs || {}; } function walk(obj, ancestors = []) { if (!obj || typeof obj !== 'object') { return; } if (ancestors.includes(obj)) {return;} if (Array.isArray(obj)) { return obj.forEach((item) => {return walk(item, [...ancestors, obj])}); } var _id = obj.$id || obj.id; if (typeof _id === 'string' && !$refs[_id]) { $refs[_id] = obj; } Object.keys(obj).forEach(function (key) { walk(obj[key], [...ancestors, obj]); }); } walk(refs); walk(schema); return $refs; }
but it crashes after in traverse function
Testable in sandbox https://codesandbox.io/s/stoic-northcutt-zzukl?file=/package.json (just run node start in terminal)
The text was updated successfully, but these errors were encountered:
I believe you meant to open the issue in json-schema-fake repo? 😃
Sorry, something went wrong.
oh sorry my bad
closing it
No branches or pull requests
In case of a schema with circular references, that is re-referenced with @apidevtools/json-schema-ref-parser for example
Circularity is not supported
version: 0.5.0-rcv.33
result
I crashed in getRefs function
I;ve test a local fix that resolves it;
but it crashes after in traverse function
Testable in sandbox https://codesandbox.io/s/stoic-northcutt-zzukl?file=/package.json (just run node start in terminal)
The text was updated successfully, but these errors were encountered: