Skip to content
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": "11.0.1",
"version": "11.0.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/programmers/internal/json_schema_jsDocTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ export const json_schema_jsDocTags = <Schema extends OpenApi.IJsonSchema>(

const value: string | undefined = tag.text
?.filter((s) => s.kind === "text")
.map((s) => s.text.split("\r\n").join("\n"))[0];
.map((s) => s.text.trim().split("\r\n").join("\n"))[0];
if (value === undefined) continue;
else (schema as any)[tag.name] = cast(value);
}
return schema;
};

const cast = (value: string): string | number | boolean => {
const cast = (value: string): string | number | boolean | null => {
if (value === "true") return true;
if (value === "false") return false;
const num: number = Number(value);
if (Number.isNaN(num) === false) return num;
return value;
return value === "null" ? null : value;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const test_pr_1714_json_schema_plugin_by_jsDocTags = (): void => {
TestValidator.equals("x-autobe-database-schema")(
(something as any)?.["x-autobe-database-schema"],
)("somethings");
TestValidator.equals("x-null-value")(
(something.properties?.id as any)?.["x-null-value"],
)(null);
TestValidator.equals("x-custom-tag")(
(something.properties?.id as any)?.["x-custom-tag"],
)(3);
Expand All @@ -36,6 +39,7 @@ interface ISomething {
* Primary Key.
*
* @x-autobe-database-schema-member id
* @x-null-value null
* @x-custom-tag 3
* @x-valid true
* @regular This is a regular tag and should be ignored.
Expand Down
Loading