mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: improve monorepo dev experience
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import {createGenerator, SchemaGenerator} from 'ts-json-schema-generator';
|
||||
import {createGenerator} from 'ts-json-schema-generator';
|
||||
import {getValidatableTypes} from './get-validatable-types.js';
|
||||
import {JSONSchema7} from 'json-schema';
|
||||
|
||||
/**
|
||||
* Compile the JSON schema for a path
|
||||
*/
|
||||
export function compileSchema(path: string, tsconfig: string): ReturnType<SchemaGenerator['createSchema']> {
|
||||
export function compileSchema(path: string, tsconfig: string): [schma: JSONSchema7, type: string] {
|
||||
const generator = createGenerator({
|
||||
path,
|
||||
tsconfig,
|
||||
@@ -23,5 +24,11 @@ export function compileSchema(path: string, tsconfig: string): ReturnType<Schema
|
||||
Object.assign(fullSchema.definitions, generator.createSchema(schema).definitions);
|
||||
}
|
||||
|
||||
return fullSchema;
|
||||
const schemaTypes = `import {JSONSchema7} from 'json-schema';\n\nexport interface SchemaMap {\n${[
|
||||
...schemaNames,
|
||||
]
|
||||
.map(schemaName => ` '${schemaName}': core.${schemaName};`)
|
||||
.join('\n')}\n}\n\nconst schema: JSONSchema7;\nexport default schema;`;
|
||||
|
||||
return [fullSchema, schemaTypes];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user