diff --git a/api.md b/api.md index 94c3f5d..7e86339 100644 --- a/api.md +++ b/api.md @@ -492,6 +492,21 @@ interface MyObject { ``` +## [comments-comment](./test/programs/comments-comment) + +```ts +/** + * @$comment Object comment + */ +interface MyObject { + /** + * @$comment Property comment + */ + text: string; +} +``` + + ## [comments-from-lib](./test/programs/comments-from-lib) ```ts @@ -607,6 +622,15 @@ export interface MyObject { ``` +## [const-as-enum](./test/programs/const-as-enum) + +```ts +export interface MyObject { + reference: true; +} +``` + + ## [const-keyword](./test/programs/const-keyword) ```ts diff --git a/test/programs/comments-comment/main.ts b/test/programs/comments-comment/main.ts new file mode 100644 index 0000000..35bd19a --- /dev/null +++ b/test/programs/comments-comment/main.ts @@ -0,0 +1,9 @@ +/** + * @$comment Object comment + */ +interface MyObject { + /** + * @$comment Property comment + */ + text: string; +} diff --git a/test/programs/comments-comment/schema.json b/test/programs/comments-comment/schema.json new file mode 100644 index 0000000..e606245 --- /dev/null +++ b/test/programs/comments-comment/schema.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "$comment": "Object comment", + "properties": { + "text": { + "$comment": "Property comment", + "type": "string" + } + }, + "required": [ + "text" + ], + "type": "object" +} + diff --git a/test/schema.test.ts b/test/schema.test.ts index a29fe97..d296250 100644 --- a/test/schema.test.ts +++ b/test/schema.test.ts @@ -371,6 +371,7 @@ describe("schema", () => { describe("comments", () => { assertSchema("comments", "MyObject"); + assertSchema("comments-comment", "MyObject"); assertSchema("comments-override", "MyObject"); assertSchema("comments-imports", "MyObject", { aliasRef: true, diff --git a/typescript-json-schema.ts b/typescript-json-schema.ts index 4043984..86f3872 100644 --- a/typescript-json-schema.ts +++ b/typescript-json-schema.ts @@ -426,6 +426,7 @@ const validationKeywords = { $ref: true, id: true, $id: true, + $comment: true, title: true };