import { JSONSchema } from '../jsonSchema' ; export function getSchemaTypeName ( schema ) { if ( schema . $id ) { const type = getSchemaRefTypeTitle ( schema . $id ) ; return type ; } if ( schema . $ref || schema . _$ref ) { const type = getSchemaRefTypeTitle ( schema . $ref || schema . _$ref ) ; return type ; } const typeStr = schema . title || ( Array . isArray ( schema . type ) ? schema . type . join ( ' | ' ) : schema . type ) ; return typeStr ; } param $ref export function getSchemaRefTypeTitle ( $ref ) { const match = $ref . match ( /^(?:.*\/)?(.*?)(?:\.schema\.json)?$/ ) ; let type = ! ! match && match [ 1 ] ; if ( ! type ) { type = 'typeNotFound' ; console . error ( `$ref (${ $ref }) not parsed properly` ) ; } return type ; }