-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore(deps-dev): bump the update-npm-dependencies group with 2 updates (
#110)
- Loading branch information
1 parent
af98434
commit b885f2e
Showing
4 changed files
with
67 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
const tsj = require("ts-json-schema-generator"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const config = { | ||
tsconfig: path.join(__dirname, "../tsconfig.json"), | ||
type: "*", | ||
extraTags: ["errorMessage"] | ||
}; | ||
import("ts-json-schema-generator").then((tsj) => { | ||
const config = { | ||
tsconfig: path.join(__dirname, "../tsconfig.json"), | ||
type: "*", | ||
extraTags: ["errorMessage"] | ||
}; | ||
|
||
const schemaGenerator = tsj.createGenerator(config); | ||
const schemaGenerator = tsj.createGenerator(config); | ||
|
||
const requestTypes = schemaGenerator | ||
.getRootNodes() | ||
.map((x) => x.symbol.escapedName) | ||
.filter((x) => x.endsWith("Request")); | ||
const requestTypes = schemaGenerator | ||
.getRootNodes() | ||
.map((x) => x.symbol.escapedName) | ||
.filter((x) => x.endsWith("Request")); | ||
|
||
const schemaDeclarations = requestTypes | ||
.map((type) => { | ||
try { | ||
const schema = schemaGenerator.createSchema(type); | ||
return `export const ${type}: any = ${JSON.stringify(schema, undefined, 4)}`; | ||
} catch (e) { | ||
if (!(e instanceof tsj.NoRootTypeError)) throw e; | ||
} | ||
}) | ||
.filter((s) => s) | ||
.join("\n\n"); | ||
const schemaDeclarations = requestTypes | ||
.map((type) => { | ||
try { | ||
const schema = schemaGenerator.createSchema(type); | ||
return `export const ${type}: any = ${JSON.stringify(schema, undefined, 4)}`; | ||
} catch (e) { | ||
if (!(e instanceof tsj.NoRootTypeError)) throw e; | ||
} | ||
}) | ||
.filter((s) => s) | ||
.join("\n\n"); | ||
|
||
const output_path = path.join(__dirname, "../src/useCases/common/Schemas.ts"); | ||
const output_path = path.join(__dirname, "../src/useCases/common/Schemas.ts"); | ||
|
||
fs.writeFile(output_path, schemaDeclarations, (err) => { | ||
if (err) throw err; | ||
fs.writeFile(output_path, schemaDeclarations, (err) => { | ||
if (err) throw err; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters