All files / generator generator.ts

92.86% Statements 13/14
75% Branches 3/4
100% Functions 4/4
92.31% Lines 12/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 421x   1x 1x   1x       8x                                   1x 8x       8x       1x 8x 8x   1x  
import { GeneratorOptionsModel } from './models/generator-options.model';
import { Draf7SchemaModel } from './models/schema.model';
import { Compiler } from './compiler';
import { AbstractSyntaxTreeBuilder } from './abstract-synthax-tree-builder';
 
export class Generator {
    private generatorOptions: GeneratorOptionsModel;
 
    constructor(generatorOptions?: GeneratorOptionsModel) {
        this.generatorOptions = generatorOptions || new GeneratorOptionsModel();
    }
 
    /**getSchemaFromDatas(data: any): any {
        console.log('Will return a JSON schema from data.');
        return null;
    }
 
    getSchemaFromPath(path: string): any {
        console.log('Will return a JSON schema from path.');
        return null;
    }
 
    getSchemaFromUrl(url: any): any {
        console.log('Will return a JSON schema from url.');
        return null;
    }**/
 
    getSchema(param: string | any): any {
        Iif (typeof param === 'string') {
            // return this.getSchemaFromPath(param);
            throw new Error('functionality not implemented yet');
        } else {
            return this.compile(param);
        }
    }
 
    private compile(jsonModel: any): Draf7SchemaModel {
        const ast = AbstractSyntaxTreeBuilder.buildNode(jsonModel);
        return Compiler.compile(ast);
    }
}