Closed mikemccabe closed 4 years ago
Hi @mikemccabe,
Yes. You are right. It's a bug. fx uses lossless-json to parse JSON (this allow fx to parse correctly 64bit integers in JSON). And it supports circular references.
The solution is to disable it:
LosslessJSON.config({circularRefs: false});
Will do it later today.
Fixed.
Confirmed! Thanks for this fix!
When I run fx on the json schema for the SendGrid API, I get an error having to do with textual circular cross-references within the document.
While it's possible that this is a real semantic issue with the document, or that it's complicated to properly parse these at the appropriate semantic level, I was surprised that fx attempted to read into and parse the string contents. What is going on? (Is there a name for this feature of json / json schema?) At the least there could be a command-line flag to skip such parsing.
The bit it chokes on is an ordinary obj key:val that looks like this:
https://api.stoplight.io/v1/versions/E2KbzZkqZQttfyqxp/export/oas.json
fx oas.json /usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/lossless-js on/dist/lossless-json.js:1 (function (exports, require, module, filename, dirname) { !function(r,e){"ob ject"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(r.LosslessJSON={})}(this,function(r){ "use strict";var e=!0;function n(r){return r&&void 0!==r.circularRefs&&null!==r. circularRefs&&(e=!0===r.circularRefs),{circularRefs:e}}var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r ){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.protot ype?"symbol":typeof r},o=function(r,e){if(!(r instanceof e))throw new TypeError( "Cannot call a class as a function")},i=function(){function r(r,e){for(var n=0;n <e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value "in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}return function(e,n,t){ return n&&r(e.prototype,n),t&&r(e,t
Error: Invalid circular reference "#/definitions/error" at /usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/loss less-json/dist/lossless-json.js:1:4798 at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4870) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336) at O (/usr/local/Cellar/fx/18.0.0/libexec/lib/node_modules/fx/node_modules/l ossless-json/dist/lossless-json.js:1:4336)