Skip to content

Commit 1d0011b

Browse files
committed
fix: avoidance $ref has been transform many times
1 parent 6136e96 commit 1d0011b

File tree

1 file changed

+2
-4
lines changed
  • packages/openapi-typescript/src

1 file changed

+2
-4
lines changed

packages/openapi-typescript/src/load.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ export default async function load(schema: URL | Subschema | Readable, options:
181181
error(`Invalid schema`);
182182
process.exit(1);
183183
}
184+
// avoidance $ref has been transform many times, use JSON.parse and JSON.stringify fix: https://github.com/drwpow/openapi-typescript/issues/1093
185+
options.schemas[schemaID].schema = JSON.parse(JSON.stringify(options.schemas[schemaID].schema));
184186

185187
// 2. resolve $refs
186188
const currentSchema = options.schemas[schemaID].schema;
@@ -256,10 +258,6 @@ export default async function load(schema: URL | Subschema | Readable, options:
256258

257259
const ref = parseRef(node.$ref);
258260

259-
// when ref.path is [], $ref has been transform, skip transform
260-
if (ref.path.length === 0 && (ref.filename.startsWith("components[") || ref.filename.startsWith("external["))) {
261-
return;
262-
}
263261
// local $ref: convert into TS path
264262
if (ref.filename === ".") {
265263
node.$ref = makeTSIndex(ref.path);

0 commit comments

Comments
 (0)