Skip to content

Commit a513013

Browse files
committed
1 parent 139f3a2 commit a513013

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-json-schema",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "typescript-json-schema generates JSON Schema files from your Typescript sources",
55
"main": "typescript-json-schema.js",
66
"bin": {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface MyObject {
1+
export interface MyObject {
22
propA: number;
33
propB: number;
44
}

test/schema.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function assertSchema(group: string, name: string, type: string) {
99
it(group + " should create correct schema", function() {
1010
let settings = TJS.defaultArgs;
1111
settings.generateRequired = true;
12+
1213
const actual = TJS.generateSchema(TJS.getProgramFromFiles([resolve(base + group + "/" + name)]), type, settings);
1314

1415
const file = readFileSync(base + group + "/schema.json", "utf8")

typescript-json-schema.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript-json-schema.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript-json-schema.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,15 @@ export module TJS {
415415
|| node.kind == ts.SyntaxKind.TypeAliasDeclaration
416416
) {
417417
const nodeType = tc.getTypeAtLocation(node);
418-
const fullName = tc.getFullyQualifiedName((<any>node).symbol)
418+
let fullName = tc.getFullyQualifiedName((<any>node).symbol)
419+
420+
// remove file name
421+
// TODO: we probably don't want this eventually,
422+
// as same types can occur in different files and will override eachother in allSymbols
423+
// This means atm we can't generate all types in large programs.
424+
fullName = fullName.replace(/".*"\./, "");
425+
426+
419427
allSymbols[fullName] = nodeType;
420428

421429
const baseTypes = nodeType.getBaseTypes() || [];
@@ -513,5 +521,5 @@ if (typeof window === "undefined" && require.main === module) {
513521
}
514522

515523
//TJS.exec("example/**/*.ts", "Invoice");
516-
//const result = TJS.generateSchema(TJS.getProgramFromFiles(["test/programs/array-types/main.ts"]), "MyArray");
524+
//const result = TJS.generateSchema(TJS.getProgramFromFiles(["test/programs/interface-single/main.ts"]), "MyObject");
517525
//console.log(JSON.stringify(result));

0 commit comments

Comments
 (0)