Skip to content

Commit

Permalink
RE: fix app crashing on recursive references
Browse files Browse the repository at this point in the history
  • Loading branch information
mtseluiko committed Jan 14, 2021
1 parent 1b900ad commit 6929ad8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ const handleMultipleTypes = (data, schema, parentSchema, definitions) => {
}
};

const resolveRecursiveReferences = (parentName, child) => {
if (!child || parentName !== child.type) {
return child;
}

child.type = 'string';

return child;
};

const addDefinitions = (types, definitions) => {
return types.map(type => {
if (Object(type) !== type) {
Expand All @@ -263,6 +273,7 @@ const addDefinitions = (types, definitions) => {
let schema = {};
const { name, namespace } = getNameAndNamespace(type.name);
type.name = name;
type = resolveRecursiveReferences(name, type);

handleRecursiveSchema(type, schema, {}, definitions);
if (namespace) {
Expand Down

0 comments on commit 6929ad8

Please sign in to comment.