Skip to content

Commit d2124fd

Browse files
FreaKnightKurtosysSean Jonker
and
Sean Jonker
authored
fix: include Title in referenced definitions (#541)
* Include Title in referenced definitions * Tests update --------- Co-authored-by: Sean Jonker <[email protected]>
1 parent d9484e8 commit d2124fd

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

Diff for: test/programs/annotation-title/main.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ interface MySubObject {
55
a: boolean;
66
}
77

8+
interface AnotherSubObject {
9+
b: boolean;
10+
}
11+
812
interface MyObject {
913
/**
1014
* @title empty#
1115
*/
1216
empty;
13-
17+
/**
18+
* @title filled
19+
*/
1420
filled: MySubObject;
21+
nonTitled: AnotherSubObject;
1522
}

Diff for: test/programs/annotation-title/schema.json

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"definitions": {
4+
"AnotherSubObject": {
5+
"properties": {
6+
"b": {
7+
"type": "boolean"
8+
}
9+
},
10+
"required": ["b"],
11+
"type": "object"
12+
},
413
"MySubObject": {
514
"title": "filled#",
615
"type": "object",
@@ -15,9 +24,13 @@
1524
"title": "empty#"
1625
},
1726
"filled": {
18-
"$ref": "#/definitions/MySubObject"
27+
"$ref": "#/definitions/MySubObject",
28+
"title": "filled"
29+
},
30+
"nonTitled": {
31+
"$ref": "#/definitions/AnotherSubObject"
1932
}
2033
},
21-
"required": ["empty", "filled"],
34+
"required": ["empty", "filled", "nonTitled"],
2235
"type": "object"
2336
}

Diff for: typescript-json-schema.ts

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ const annotationKeywords: { [k in keyof typeof validationKeywords]?: true } = {
438438
description: true,
439439
default: true,
440440
examples: true,
441+
title: true,
441442
// A JSDoc $ref annotation can appear as a $ref.
442443
$ref: true,
443444
};

0 commit comments

Comments
 (0)