Commit 55860e5b authored by nanahira's avatar nanahira

catchup for toString method

parent 74ea4157
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
"jest": "^27.4.3", "jest": "^27.4.3",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"schemastery": "^2.1.0", "schemastery": "^2.1.1",
"ts-jest": "^27.0.7", "ts-jest": "^27.0.7",
"typescript": "^4.5.2" "typescript": "^4.5.2"
}, },
...@@ -4545,9 +4545,9 @@ ...@@ -4545,9 +4545,9 @@
} }
}, },
"node_modules/schemastery": { "node_modules/schemastery": {
"version": "2.1.0", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.0.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.1.tgz",
"integrity": "sha512-D5wGNn5lc8GnhTzSl2ClH6RwUB69NMUrIXn6qWJVZSSq1fJtEodL9zXoJUbzoLQlL7rGMuO6entajhZvJY25Tw==", "integrity": "sha512-ORumqcbLhe4fp+eN5COUFejTxvdfAUCQCFVF4c69HuFdexbU8kgqQsOHjJ3ZXokV15xstwWHPwAVQ8/AwldROw==",
"dev": true "dev": true
}, },
"node_modules/semver": { "node_modules/semver": {
...@@ -8711,9 +8711,9 @@ ...@@ -8711,9 +8711,9 @@
} }
}, },
"schemastery": { "schemastery": {
"version": "2.1.0", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.0.tgz", "resolved": "https://registry.npmjs.org/schemastery/-/schemastery-2.1.1.tgz",
"integrity": "sha512-D5wGNn5lc8GnhTzSl2ClH6RwUB69NMUrIXn6qWJVZSSq1fJtEodL9zXoJUbzoLQlL7rGMuO6entajhZvJY25Tw==", "integrity": "sha512-ORumqcbLhe4fp+eN5COUFejTxvdfAUCQCFVF4c69HuFdexbU8kgqQsOHjJ3ZXokV15xstwWHPwAVQ8/AwldROw==",
"dev": true "dev": true
}, },
"semver": { "semver": {
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
"jest": "^27.4.3", "jest": "^27.4.3",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"schemastery": "^2.1.0", "schemastery": "^2.1.1",
"ts-jest": "^27.0.7", "ts-jest": "^27.0.7",
"typescript": "^4.5.2" "typescript": "^4.5.2"
}, },
"peerDependencies": { "peerDependencies": {
"schemastery": "^2.1.0" "schemastery": "^2.1.1"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
......
...@@ -102,6 +102,7 @@ const schemaFields: (keyof Schema)[] = [ ...@@ -102,6 +102,7 @@ const schemaFields: (keyof Schema)[] = [
const schemaFunctions: (keyof Schema)[] = [ const schemaFunctions: (keyof Schema)[] = [
'toJSON', 'toJSON',
// 'toString',
'required', 'required',
'hidden', 'hidden',
'adaptive', 'adaptive',
...@@ -165,6 +166,7 @@ export function SchemaClass<T>(originalClass: ClassType<T>) { ...@@ -165,6 +166,7 @@ export function SchemaClass<T>(originalClass: ClassType<T>) {
}); });
} }
newClass.toString = schema.toString.bind(schema);
newClass[kSchema] = true; newClass[kSchema] = true;
return newClass; return newClass;
} }
......
...@@ -56,4 +56,9 @@ describe('Schema registration', () => { ...@@ -56,4 +56,9 @@ describe('Schema registration', () => {
const newSchema = schema.description('foo'); const newSchema = schema.description('foo');
expect(newSchema.meta.description).toBe('foo'); expect(newSchema.meta.description).toBe('foo');
}); });
it('should work in toString method', () => {
const schema = Config as Schema<Config>;
expect(schema.toString(true)).toBe('{ foo?: string }');
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment