mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
feat: improve monorepo dev experience
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import {createGenerator, SchemaGenerator} from 'ts-json-schema-generator';
|
||||
import {getValidatableTypes} from './get-validatable-types.js';
|
||||
|
||||
/**
|
||||
* Compile the JSON schema for a path
|
||||
*/
|
||||
export function compileSchema(path: string, tsconfig: string): ReturnType<SchemaGenerator['createSchema']> {
|
||||
const generator = createGenerator({
|
||||
path,
|
||||
tsconfig,
|
||||
extraTags: ['elasticsearch'],
|
||||
skipTypeCheck: true,
|
||||
});
|
||||
// @ts-expect-error private access
|
||||
const program = generator.program;
|
||||
const schemaNames = getValidatableTypes(program);
|
||||
const fullSchema = {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
definitions: {},
|
||||
};
|
||||
|
||||
for (const schema of schemaNames) {
|
||||
Object.assign(fullSchema.definitions, generator.createSchema(schema).definitions);
|
||||
}
|
||||
|
||||
return fullSchema;
|
||||
}
|
||||
Reference in New Issue
Block a user