mirror of
https://github.com/stoatchat/javascript-client-api.git
synced 2026-08-26 12:35:48 -04:00
24 lines
753 B
TypeScript
24 lines
753 B
TypeScript
import convert from '@openapi-contrib/json-schema-to-openapi-schema';
|
|
import { generator, type_files } from '../typescript.js';
|
|
import * as TJS from "typescript-json-schema";
|
|
import { readFileSync } from "fs";
|
|
|
|
const TYPE_RE = /(?:type|enum|interface) (\w+)/g
|
|
export default async function() {
|
|
let types: string[] = [];
|
|
for (const path of type_files) {
|
|
const f = readFileSync(path).toString();
|
|
types = types.concat([...f.matchAll(TYPE_RE)].map(x => x[1]));
|
|
}
|
|
|
|
let definitions: { [key: string]: TJS.Definition } = {};
|
|
for (let type of types) {
|
|
const defn = generator?.getSchemaForSymbol(type);
|
|
if (defn) {
|
|
definitions[type] = await convert(defn);
|
|
}
|
|
}
|
|
|
|
return definitions;
|
|
}
|