Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: $comment keyword #604

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading