diff --git a/test/programs/annotation-title/main.ts b/test/programs/annotation-title/main.ts new file mode 100644 index 00000000..af7b9d50 --- /dev/null +++ b/test/programs/annotation-title/main.ts @@ -0,0 +1,15 @@ +/** + * @title filled# + */ +interface MySubObject { + a: boolean; +} + +interface MyObject { + /** + * @title empty# + */ + empty; + + filled: MySubObject; +} diff --git a/test/programs/annotation-title/schema.json b/test/programs/annotation-title/schema.json new file mode 100644 index 00000000..7d11b17b --- /dev/null +++ b/test/programs/annotation-title/schema.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "MySubObject": { + "title": "filled#", + "type": "object", + "properties": { + "a": { "type": "boolean" } + }, + "required": ["a"] + } + }, + "properties": { + "empty": { + "title": "empty#" + }, + "filled": { + "$ref": "#/definitions/MySubObject" + } + }, + "required": ["empty", "filled"], + "type": "object" +} diff --git a/test/schema.test.ts b/test/schema.test.ts index ea076df3..26352eb6 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -259,19 +259,15 @@ describe("schema", () => { describe("annotations", () => { assertSchema("annotation-default", "MyObject"); assertSchema("annotation-ref", "MyObject", {}, undefined, undefined, { - skipCompile: true + skipCompile: true, }); assertSchema("annotation-tjs", "MyObject", { validationKeywords: ["hide"], }); assertSchema("annotation-id", "MyObject", {}, undefined, undefined, { - expectedWarnings: [ - "schema id ignored", - "schema id ignored", - "schema id ignored", - "schema id ignored" - ] + expectedWarnings: ["schema id ignored", "schema id ignored", "schema id ignored", "schema id ignored"], }); + assertSchema("annotation-title", "MyObject"); assertSchema("annotation-items", "MyObject"); assertSchema("typeof-keyword", "MyObject", { typeOfKeyword: true }); @@ -461,6 +457,6 @@ describe("tsconfig.json", () => { describe("Functionality 'required' in annotation", () => { assertSchema("annotation-required", "MyObject", { - tsNodeRegister: true + tsNodeRegister: true, }); }); diff --git a/typescript-json-schema.ts b/typescript-json-schema.ts index 610e02b4..87236ad4 100644 --- a/typescript-json-schema.ts +++ b/typescript-json-schema.ts @@ -416,7 +416,8 @@ const validationKeywords = { format: true, default: true, $ref: true, - id: true + id: true, + title: true }; /**