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 20bb8a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"editor.rulers": [
80
],
"editor.rulers": [80],
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ describe('build-schema', () => {
},
});
});
it('does not pollute the JSON schema options', () => {
@model()
class Category {
@property()
name: string;
}

const JSON_SCHEMA_OPTIONS = {};
// tslint:disable-next-line:no-unused
const categorySchema = getJsonSchema(Category, JSON_SCHEMA_OPTIONS);
expect(JSON_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 20bb8a2

Please sign in to comment.