Skip to content

Commit 8a128fd

Browse files
committed
attempting to replace bad refs
1 parent 5b7382e commit 8a128fd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/schema-builder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class ZodSchemaBuilder<R extends Record<string, JsonSchema7Type>> {
1010
}
1111

1212
add<S extends string, T extends z.ZodType>(name: S, type: T): ZodSchemaBuilder<R & {[name in S]: JsonSchema7Type}> {
13-
this.schemas[name] = (zodToJsonSchema(type, {name, basePath: ['#','components', 'schemas'], '$refStrategy': 'none' }).definitions as any)[name];
13+
this.schemas[name] = (zodToJsonSchema(type, {name, basePath: ['#','components', 'schemas'], '$refStrategy': 'root', postProcess: s => {
14+
return JSON.parse(JSON.stringify(s).replaceAll('#/components/schemas/definitions/', '#/components/schemas/'))
15+
} }).definitions as any)[name];
1416
this.schemas[name].title = name;
1517
return this as any;
1618
}

0 commit comments

Comments
 (0)