Skip to content

Commit

Permalink
Fix wrong $ref address for recursive array type.
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Nov 10, 2024
1 parent f58063c commit bb3a438
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.11.2.tgz"
"typia": "../typia-6.11.4.tgz"
}
}
2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.11.2.tgz"
"typia": "../typia-6.11.4.tgz"
}
}
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": "6.11.3",
"version": "6.11.4",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
13 changes: 8 additions & 5 deletions src/programmers/internal/application_array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ export const application_array =
array.tags,
);
if (array.type.recursive === true) {
const out = () => [{ $ref }];
const $ref: string = `#/components/schemas/${array.type.name}`;
if (components.schemas?.[$ref] !== undefined) return out();
const out = () => [
{
$ref: `#/components/schemas/${array.type.name}`,
},
];
if (components.schemas?.[array.type.name] !== undefined) return out();

components.schemas ??= {};
components.schemas[$ref] ??= {};
components.schemas[array.type.name] ??= {};

const oneOf: ArraySchema<Version>[] = factory();
Object.assign(
components.schemas[$ref]!,
components.schemas[array.type.name]!,
oneOf.length === 1 ? oneOf[0] : { oneOf },
);
return out();
Expand Down
2 changes: 1 addition & 1 deletion test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"typia": "../typia-6.11.2.tgz"
"typia": "../typia-6.11.4.tgz"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.11.2.tgz"
"typia": "../typia-6.11.4.tgz"
}
}
2 changes: 1 addition & 1 deletion test/schemas/json/v3_0/ArrayRepeatedNullable.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedNullable": {
"ArrayArrayRepeatedNullable": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedNullable"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_0/ArrayRepeatedRequired.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedRequired": {
"ArrayArrayRepeatedRequired": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedRequired"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_0/ArrayRepeatedUnion.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedUnion": {
"ArrayArrayRepeatedUnion": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedUnion"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_0/ArrayRepeatedUnionWithTuple.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedUnionWithTuple": {
"ArrayArrayRepeatedUnionWithTuple": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedUnionWithTuple"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_1/ArrayRepeatedNullable.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedNullable": {
"ArrayArrayRepeatedNullable": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedNullable"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_1/ArrayRepeatedRequired.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedRequired": {
"ArrayArrayRepeatedRequired": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedRequired"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_1/ArrayRepeatedUnion.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedUnion": {
"ArrayArrayRepeatedUnion": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedUnion"
Expand Down
2 changes: 1 addition & 1 deletion test/schemas/json/v3_1/ArrayRepeatedUnionWithTuple.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
]
},
"#/components/schemas/ArrayArrayRepeatedUnionWithTuple": {
"ArrayArrayRepeatedUnionWithTuple": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ArrayRepeatedUnionWithTuple"
Expand Down

0 comments on commit bb3a438

Please sign in to comment.