Skip to content

Commit

Permalink
fixup!: avoid polluting the options
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Apr 16, 2019
1 parent 5ab7796 commit c15b4f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ describe('build-schema', () => {
},
});
});
it('does not pollute the options', () => {
@model()
class Category {
@property()
name: string;
}

const SCHEMA_OPTIONS = {};
// tslint:disable-next-line:no-unused
const categorySchema = getJsonSchema(Category, SCHEMA_OPTIONS);
expect(SCHEMA_OPTIONS).to.be.empty();
});
context('circular reference', () => {
@model()
class Category {
Expand Down
3 changes: 2 additions & 1 deletion packages/repository-json-schema/src/build-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ export function metaToJsonProperty(meta: PropertyDefinition): JSONSchema {
*/
export function modelToJsonSchema(
ctor: Function,
options: JsonSchemaOptions = {},
jsonSchemaOptions: JsonSchemaOptions = {},
): JSONSchema {
const options = {...jsonSchemaOptions};
options.visited = options.visited || {};

const meta: ModelDefinition | {} = ModelMetadataHelper.getModelMetadata(ctor);
Expand Down

0 comments on commit c15b4f7

Please sign in to comment.