Skip to content

Commit 1f15121

Browse files
authored
Merge pull request #72 from json-schema-tools/feat/deref
Feat/deref
2 parents e2dda4a + a4e85ba commit 1f15121

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,5 @@ workflows:
8686
filters: *filter-only-master
8787
context: sem-rel-json-schema-tools
8888
requires:
89-
- hold
9089
- build
9190
- test

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"typescript": "^3.9.6"
3131
},
3232
"dependencies": {
33+
"@json-schema-tools/dereferencer": "^1.0.15",
3334
"@json-schema-tools/transpiler": "^1.2.1",
3435
"lodash": "^4.17.15",
3536
"node-typescript-compiler": "^2.1.2"

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { camelCase, snakeCase, upperFirst } from "lodash";
66
import * as fs from "fs";
77
import { promisify } from "util";
88
import { JSONMetaSchema } from "@json-schema-tools/meta-schema";
9+
import Dereferencer from "@json-schema-tools/dereferencer";
910

1011
const readFile = promisify(fs.readFile);
1112
const writeFile = promisify(fs.writeFile);
@@ -119,7 +120,15 @@ export const prepare: PluginFunction = async (pluginConfig, context): Promise<bo
119120
throw new SemanticReleaseError("The schema must have a title", "ENOTITLE", "Schema requires a title");
120121
}
121122

122-
const transpiler = new Transpiler(schema);
123+
let dereffedSchema;
124+
try {
125+
const dereffer = new Dereferencer(schema);
126+
dereffedSchema = await dereffer.resolve();
127+
} catch (e) {
128+
throw new SemanticReleaseError(e.message);
129+
}
130+
131+
const transpiler = new Transpiler(dereffedSchema);
123132

124133
if (!pluginConfig.languages || pluginConfig.languages.ts) {
125134
await generateTs(transpiler, schema, outpath);

0 commit comments

Comments
 (0)