Skip to content

Commit

Permalink
Added missing interpreter for items
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed May 20, 2021
1 parent 571e490 commit 49348fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interpreter/Interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import interpretProperties from './InterpretProperties';
import interpretAllOf from './InterpretAllOf';
import interpretConst from './InterpretConst';
import { Logger } from '../utils';
import interpretItems from './InterpretItems';

export class Interpreter {
static defaultOptions: SimplificationOptions = {
Expand Down Expand Up @@ -78,7 +79,8 @@ export class Interpreter {
}

model.required = schema.required || model.required;


interpretItems(schema, model, this);
interpretProperties(schema, model, this);
interpretAllOf(schema, model, this);
interpretConst(schema, model);
Expand Down
8 changes: 8 additions & 0 deletions test/interpreter/Intepreter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {isModelObject, interpretName} from '../../src/interpreter/Utils';
import interpretProperties from '../../src/interpreter/InterpretProperties';
import interpretConst from '../../src/interpreter/InterpretConst';
import interpretAllOf from '../../src/interpreter/InterpretAllOf';
import interpretItems from '../../src/interpreter/InterpretItems';
import { CommonModel, Schema } from '../../src/models';

let mockedIsModelObjectReturn = false;
Expand All @@ -17,6 +18,7 @@ jest.mock('../../src/interpreter/Utils', () => {
jest.mock('../../src/interpreter/InterpretProperties');
jest.mock('../../src/interpreter/InterpretConst');
jest.mock('../../src/interpreter/InterpretAllOf');
jest.mock('../../src/interpreter/InterpretItems');
CommonModel.mergeCommonModels = jest.fn();
/**
* Some of these test are purely theoretical and have little if any merit
Expand Down Expand Up @@ -176,6 +178,12 @@ describe('Interpreter', function() {
interpreter.interpret(schema);
expect(interpretAllOf).toHaveBeenNthCalledWith(1, schema, expect.anything(), expect.anything());
});
test('should always try to interpret items', function() {
const schema = {};
const interpreter = new Interpreter();
interpreter.interpret(schema);
expect(interpretItems).toHaveBeenNthCalledWith(1, schema, expect.anything(), expect.anything());
});

test('should support primitive roots', function() {
const schema = { 'type': 'string' };
Expand Down

0 comments on commit 49348fb

Please sign in to comment.