-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from hey-api/fix/zod-plugin-circular-ref
fix: zod plugin handles recursive schemas
- Loading branch information
Showing
7 changed files
with
165 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: zod plugin handles recursive schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/openapi-ts/test/__snapshots__/3.1.x/schema-recursive/zod.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import { z } from 'zod'; | ||
|
||
export const zFoo: z.ZodTypeAny = z.object({ | ||
foo: z.string().optional(), | ||
bar: z.object({ | ||
foo: z.lazy(() => { | ||
return zFoo; | ||
}).optional() | ||
}).optional(), | ||
baz: z.array(z.lazy(() => { | ||
return zFoo; | ||
})).optional() | ||
}); | ||
|
||
export const zBar = z.object({ | ||
foo: zFoo.optional() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"openapi": "3.1.0", | ||
"info": { | ||
"title": "OpenAPI 3.1.0 schema recursive example", | ||
"version": "1" | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Foo": { | ||
"type": "object", | ||
"properties": { | ||
"foo": { | ||
"type": "string" | ||
}, | ||
"bar": { | ||
"$ref": "#/components/schemas/Bar" | ||
}, | ||
"baz": { | ||
"items": { | ||
"$ref": "#/components/schemas/Foo" | ||
}, | ||
"type": "array" | ||
} | ||
} | ||
}, | ||
"Bar": { | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/components/schemas/Foo" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} |