Skip to content

Commit

Permalink
feat: $comment keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasconsolidity committed May 30, 2024
1 parent 54a651c commit cc27218
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/programs/comments-comment/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @$comment Object comment
*/
interface MyObject {
/**
* @$comment Property comment
*/
text: string;
}
16 changes: 16 additions & 0 deletions test/programs/comments-comment/schema.json
Original file line number Diff line number Diff line change
@@ -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"
}

1 change: 1 addition & 0 deletions test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions typescript-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ const validationKeywords = {
$ref: true,
id: true,
$id: true,
$comment: true,
title: true
};

Expand Down

0 comments on commit cc27218

Please sign in to comment.