Skip to content

Commit

Permalink
fix: include Title in referenced definitions (#541)
Browse files Browse the repository at this point in the history
* Include Title in referenced definitions

* Tests update

---------

Co-authored-by: Sean Jonker <[email protected]>
  • Loading branch information
FreaKnightKurtosys and Sean Jonker authored May 15, 2023
1 parent d9484e8 commit d2124fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion test/programs/annotation-title/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ interface MySubObject {
a: boolean;
}

interface AnotherSubObject {
b: boolean;
}

interface MyObject {
/**
* @title empty#
*/
empty;

/**
* @title filled
*/
filled: MySubObject;
nonTitled: AnotherSubObject;
}
17 changes: 15 additions & 2 deletions test/programs/annotation-title/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AnotherSubObject": {
"properties": {
"b": {
"type": "boolean"
}
},
"required": ["b"],
"type": "object"
},
"MySubObject": {
"title": "filled#",
"type": "object",
Expand All @@ -15,9 +24,13 @@
"title": "empty#"
},
"filled": {
"$ref": "#/definitions/MySubObject"
"$ref": "#/definitions/MySubObject",
"title": "filled"
},
"nonTitled": {
"$ref": "#/definitions/AnotherSubObject"
}
},
"required": ["empty", "filled"],
"required": ["empty", "filled", "nonTitled"],
"type": "object"
}
1 change: 1 addition & 0 deletions typescript-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ const annotationKeywords: { [k in keyof typeof validationKeywords]?: true } = {
description: true,
default: true,
examples: true,
title: true,
// A JSDoc $ref annotation can appear as a $ref.
$ref: true,
};
Expand Down

0 comments on commit d2124fd

Please sign in to comment.