From 8b44a588a4765cbb290691c2b5a7d80649c79789 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 26 Oct 2024 15:00:47 -0400 Subject: [PATCH] fix: Change RepoModule into a union with oneOf --- .gitignore | 8 ++++---- fetchModuleSchemas.js | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f193069..3c815ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -tsp-output/* -node_modules/* -dist/* -src-tsp/modules/* \ No newline at end of file +tsp-output/ +node_modules/ +dist/ +src-tsp/modules/ diff --git a/fetchModuleSchemas.js b/fetchModuleSchemas.js index 6f56858..02cbf22 100644 --- a/fetchModuleSchemas.js +++ b/fetchModuleSchemas.js @@ -41,5 +41,12 @@ for (const module of modules) { fs.writeFileSync(`${modulesDir}/index.tsp`, moduleImports.map(m => `import "./${m}";`).join("\n") + ` -alias RepoModule = ${moduleModels.map(m => `${m}Module`).join(" | ")};` -) \ No newline at end of file +import "@typespec/json-schema"; + +using TypeSpec.JsonSchema; + +@oneOf +union RepoModule { +${moduleModels.map(m => ` ${m}Module`).join(",\n")} +}` +)