Skip to content

Commit d86e10c

Browse files
committed
SchemaProvider: Rename schema_path to schemaPath
Also include an alias so schema_path can still be used for backwards compatibility.
1 parent 5fa8e48 commit d86e10c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/schema_provider.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@ class FsSchemaProvider extends BaseSchemaProvider {
6262
constructor(schemaRootPath) {
6363
super();
6464

65-
this.schema_path = schemaRootPath;
65+
this.schemaPath = schemaRootPath;
66+
}
67+
68+
get schema_path() {
69+
return this.schemaPath;
70+
}
71+
72+
set schema_path(value) {
73+
this.schemaPath = value;
6674
}
6775

6876
_loadSchema(schemaName) {
6977
return new Promise((resolve, reject) => {
70-
fs.readFile(`${this.schema_path}/${schemaName}.json`, (err, data) => {
78+
fs.readFile(`${this.schemaPath}/${schemaName}.json`, (err, data) => {
7179
if (err) return reject(err);
7280
return resolve(data.toString('utf8'));
7381
});
@@ -81,7 +89,7 @@ class FsSchemaProvider extends BaseSchemaProvider {
8189
*/
8290
list() {
8391
return new Promise((resolve, reject) => {
84-
fs.readdir(this.schema_path, (err, data) => {
92+
fs.readdir(this.schemaPath, (err, data) => {
8593
if (err) return reject(err);
8694

8795
const list = data.filter(x => x.endsWith('.json'))

test/schema_provider.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ describe('schema provider tests', function () {
7171
assert.isRejected(provider.fetch('f5'))
7272
]);
7373
});
74+
75+
it('schema_path_alias', function () {
76+
const provider = new FsSchemaProvider(schemasPath);
77+
78+
provider.schema_path = 'foo';
79+
assert.strictEqual(provider.schemaPath, provider.schema_path);
80+
});
7481
});
7582

7683
describe('DataStoreSchemaProvider', function () {

0 commit comments

Comments
 (0)