Skip to content

Commit

Permalink
fix(core): added better error for missing references
Browse files Browse the repository at this point in the history
  • Loading branch information
grantila committed Apr 7, 2021
1 parent 00c0f2e commit e3db774
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/json-schema-to-suretype.ts
Expand Up @@ -141,6 +141,15 @@ export function convertJsonSchemaToSureType(
topLevelType: '',
};

const definedDefinitions = Object.keys( definitions );
[ ...cyclic, ...nonCyclic ].forEach( definition =>
{
if ( !definedDefinitions.includes( definition ) )
{
throw new MissingReferenceError( definition, coreContext.meta( ) );
}
} );

const jsonSchemaAsCoreTypes = convertJsonSchemaToCoreTypes( jsonSchema );
const coreTypes = simplify( jsonSchemaAsCoreTypes.data );

Expand Down

0 comments on commit e3db774

Please sign in to comment.