Skip to content

Commit 1bbf4a9

Browse files
authored
feat: $comment keyword (YousefED#604)
1 parent 54a651c commit 1bbf4a9

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

api.md

+24
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,21 @@ interface MyObject {
492492
```
493493

494494

495+
## [comments-comment](./test/programs/comments-comment)
496+
497+
```ts
498+
/**
499+
* @$comment Object comment
500+
*/
501+
interface MyObject {
502+
/**
503+
* @$comment Property comment
504+
*/
505+
text: string;
506+
}
507+
```
508+
509+
495510
## [comments-from-lib](./test/programs/comments-from-lib)
496511

497512
```ts
@@ -607,6 +622,15 @@ export interface MyObject {
607622
```
608623

609624

625+
## [const-as-enum](./test/programs/const-as-enum)
626+
627+
```ts
628+
export interface MyObject {
629+
reference: true;
630+
}
631+
```
632+
633+
610634
## [const-keyword](./test/programs/const-keyword)
611635

612636
```ts
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @$comment Object comment
3+
*/
4+
interface MyObject {
5+
/**
6+
* @$comment Property comment
7+
*/
8+
text: string;
9+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"additionalProperties": false,
4+
"$comment": "Object comment",
5+
"properties": {
6+
"text": {
7+
"$comment": "Property comment",
8+
"type": "string"
9+
}
10+
},
11+
"required": [
12+
"text"
13+
],
14+
"type": "object"
15+
}
16+

test/schema.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ describe("schema", () => {
371371

372372
describe("comments", () => {
373373
assertSchema("comments", "MyObject");
374+
assertSchema("comments-comment", "MyObject");
374375
assertSchema("comments-override", "MyObject");
375376
assertSchema("comments-imports", "MyObject", {
376377
aliasRef: true,

typescript-json-schema.ts

+1
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ const validationKeywords = {
426426
$ref: true,
427427
id: true,
428428
$id: true,
429+
$comment: true,
429430
title: true
430431
};
431432

0 commit comments

Comments
 (0)