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

Close #729 - @hidden tag for JSON schema #730

Merged
merged 1 commit into from
Jul 31, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "4.1.11",
"version": "4.1.12",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "4.1.11",
"version": "4.1.12",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "4.1.11"
"typia": "4.1.12"
},
"peerDependencies": {
"typescript": ">= 4.7.4"
Expand Down
3 changes: 3 additions & 0 deletions src/programmers/internal/application_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ export const application_object =

for (const property of obj.properties) {
if (
// FUNCTIONAL TYPE
property.value.functional === true &&
property.value.nullable === false &&
property.value.isRequired() === true &&
property.value.size() === 0
)
continue;
else if (property.jsDocTags.find((tag) => tag.name === "hidden"))
continue; // THE HIDDEN TAG

const key: string | null = property.key.getSoleLiteral();
const schema: IJsonSchema | null = application_schema(options)(
Expand Down
28 changes: 28 additions & 0 deletions test/features/issues/test_issue_hidden_comment_tag.ts
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 test/generated/output/issues/test_issue_hidden_comment_tag.ts
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.",
);
};
14 changes: 14 additions & 0 deletions test/issues/hidden.ts
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"]
Loading
Loading