diff --git a/api/scripts/generate_test_schema.ts b/api/scripts/generate_body_schema.js
index eed77738..22d0b02e 100644
--- a/api/scripts/generate_test_schema.ts
+++ b/api/scripts/generate_body_schema.js
@@ -4,9 +4,9 @@ import path from "path";
import fs from "fs";
import * as TJS from "typescript-json-schema";
import "missing-native-js-functions";
-const schemaPath = path.join(__dirname, "..", "assets", "responses.json");
+const schemaPath = path.join(__dirname, "..", "assets", "schemas.json");
-const settings: TJS.PartialArgs = {
+const settings = {
required: true,
ignoreErrors: true,
excludePrivate: true,
@@ -14,10 +14,13 @@ const settings: TJS.PartialArgs = {
noExtraProps: true,
defaultProps: false
};
-const compilerOptions: TJS.CompilerOptions = {
+const compilerOptions = {
strictNullChecks: true
};
-const ExcludedSchemas = [
+const Excluded = [
+ "DefaultSchema",
+ "Schema",
+ "EntitySchema",
"ServerResponse",
"Http2ServerResponse",
"global.Express.Response",
@@ -32,13 +35,13 @@ function main() {
const generator = TJS.buildGenerator(program, settings);
if (!generator || !program) return;
- const schemas = generator.getUserSymbols().filter((x) => x.endsWith("Response") && !ExcludedSchemas.includes(x));
+ const schemas = generator.getUserSymbols().filter((x) => (x.endsWith("Schema") || x.endsWith("Response")) && !Excluded.includes(x));
console.log(schemas);
- var definitions: any = {};
+ var definitions = {};
for (const name of schemas) {
- const part = TJS.generateSchema(program, name, settings, [], generator as TJS.JsonSchemaGenerator);
+ const part = TJS.generateSchema(program, name, settings, [], generator);
if (!part) continue;
definitions = { ...definitions, [name]: { ...part } };
@@ -47,11 +50,10 @@ function main() {
fs.writeFileSync(schemaPath, JSON.stringify(definitions, null, 4));
}
-// #/definitions/
main();
-function walk(dir: string) {
- var results = [] as string[];
+function walk(dir) {
+ var results = [];
var list = fs.readdirSync(dir);
list.forEach(function (file) {
file = dir + "/" + file;
|