-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
> This is a feature requested by sponsor @windofwind. When `@hidden` comment tag being used, let JSON schema generator to ignore that property. Unlike `@internal` tag, it would not affect to other `typia` functions like `typia.assert<T>()`. ```typescript import typia from "typia"; interface ISomething { id: string; /** * @hidden */ authority: number; } const app: typia.IJsonApplication = typia.application<[ISomething], "ajv">(); const object: typia.IJsonComponents.IObject = (app.components.schemas ?? {}) .ISomething as typia.IJsonComponents.IObject; console.log(Object.keys(object.properties)); // ["id"] ```
- Loading branch information
Showing
10 changed files
with
162 additions
and
862 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import typia from "typia"; | ||
|
||
interface ISomething { | ||
/** | ||
* @format uuid | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
authority: number; | ||
} | ||
|
||
export const test_issue_hidden_comment_tag = () => { | ||
const app: typia.IJsonApplication = typia.application< | ||
[ISomething], | ||
"ajv" | ||
>(); | ||
const object: typia.IJsonComponents.IObject = (app.components.schemas ?? {}) | ||
.ISomething as typia.IJsonComponents.IObject; | ||
const keys: string[] = Object.keys(object.properties); | ||
|
||
if (keys.length !== 1 || keys[0] !== "id") | ||
throw new Error( | ||
"Bug on typia.application: failed to understand the hidden comment tag.", | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
test/generated/output/issues/test_issue_hidden_comment_tag.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import typia from "typia"; | ||
|
||
interface ISomething { | ||
/** | ||
* @format uuid | ||
*/ | ||
id: string; | ||
/** | ||
* @hidden | ||
*/ | ||
authority: number; | ||
} | ||
export const test_issue_hidden_comment_tag = () => { | ||
const app: typia.IJsonApplication = typia.application< | ||
[ISomething], | ||
"ajv" | ||
>(); | ||
const object: typia.IJsonComponents.IObject = (app.components.schemas ?? {}) | ||
.ISomething as typia.IJsonComponents.IObject; | ||
const keys: string[] = Object.keys(object.properties); | ||
if (keys.length !== 1 || keys[0] !== "id") | ||
throw new Error( | ||
"Bug on typia.application: failed to understand the hidden comment tag.", | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import typia from "typia"; | ||
|
||
interface ISomething { | ||
id: string; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
authority: number; | ||
} | ||
const app: typia.IJsonApplication = typia.application<[ISomething], "ajv">(); | ||
const object: typia.IJsonComponents.IObject = (app.components.schemas ?? {}) | ||
.ISomething as typia.IJsonComponents.IObject; | ||
console.log(Object.keys(object.properties)); // ["id"] |
Oops, something went wrong.