-
-
Notifications
You must be signed in to change notification settings - Fork 245
Closed
Labels
bug 🔥Something isn't workingSomething isn't workingjavascriptPull requests that update Javascript codePull requests that update Javascript code
Description
Heyapi config:
import { defineConfig } from '@hey-api/openapi-ts';
export default defineConfig({
input: './test.yaml',
output: {
format: 'prettier',
lint: 'eslint',
path: './src/client',
},
plugins: [
{
name: 'zod',
types: {
infer: true,
},
},
],
});
OpenAPI specification
openapi: '3.0.3'
info:
title: Test
components:
requestBodies:
req:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/body'
schemas:
body:
type: array
items:
allOf:
- type: object
properties:
id:
type: integer
- type: object
properties:
name:
type: string
Generated zod schema
// This file is auto-generated by @hey-api/openapi-ts
import { z } from 'zod';
export const zBody = z.array(
z.union([
z.object({
id: z.optional(z.int()),
}),
z.object({
name: z.optional(z.string()),
}),
]),
);
export type BodyZodType = z.infer<typeof zBody>;
export const zReq = zBody;
export type ReqZodType = z.infer<typeof zReq>;
But I expect .and or .intersection instead of .union
mrlubosCopilot
Metadata
Metadata
Assignees
Labels
bug 🔥Something isn't workingSomething isn't workingjavascriptPull requests that update Javascript codePull requests that update Javascript code