@orpc/zod 0.0.0-next.b6be6f0 → 0.0.0-next.bc564a6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -528,6 +528,16 @@ function zodToJsonSchema(schema, options) {
528
528
  return {};
529
529
  }
530
530
  const schema__ = schema;
531
+ if (!options?.isHandledZodDescription && "description" in schema__._def) {
532
+ const json = zodToJsonSchema(schema__, {
533
+ ...options,
534
+ isHandledZodDescription: true
535
+ });
536
+ return {
537
+ description: schema__._def.description,
538
+ ...json
539
+ };
540
+ }
531
541
  if (!options?.isHandledCustomJSONSchema) {
532
542
  const customJSONSchema = getCustomJSONSchema(schema__._def, options);
533
543
  if (customJSONSchema) {
@@ -541,7 +551,7 @@ function zodToJsonSchema(schema, options) {
541
551
  };
542
552
  }
543
553
  }
544
- const childOptions = { ...options, isHandledCustomJSONSchema: false };
554
+ const childOptions = { ...options, isHandledCustomJSONSchema: false, isHandledZodDescription: false };
545
555
  const customType = getCustomZodType(schema__._def);
546
556
  switch (customType) {
547
557
  case "Blob": {
@@ -714,6 +724,7 @@ function zodToJsonSchema(schema, options) {
714
724
  const schema_ = schema__;
715
725
  const def = schema_._def;
716
726
  const json = { type: "array" };
727
+ json.items = zodToJsonSchema(def.type, childOptions);
717
728
  if (def.exactLength) {
718
729
  json.maxItems = def.exactLength.value;
719
730
  json.minItems = def.exactLength.value;
@@ -35,6 +35,12 @@ export interface ZodToJsonSchemaOptions {
35
35
  * @internal
36
36
  */
37
37
  isHandledCustomJSONSchema?: boolean;
38
+ /**
39
+ * Track if current level schema is handled zod description to prevent recursive
40
+ *
41
+ * @internal
42
+ */
43
+ isHandledZodDescription?: boolean;
38
44
  }
39
45
  export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema.JSONSchema, boolean>;
40
46
  export declare class ZodToJsonSchemaConverter implements SchemaConverter {
@@ -10,7 +10,7 @@ export declare function getCustomJSONSchema(def: ZodTypeDef, options?: {
10
10
  mode?: 'input' | 'output';
11
11
  }): Exclude<JSONSchema, boolean> | undefined;
12
12
  export declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>> & {
13
- type: (mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)) => ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
13
+ type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
14
14
  };
15
15
  export declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof Blob>, ZodTypeDef, InstanceType<typeof Blob>>;
16
16
  export declare function invalidDate(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Date, ZodTypeDef, Date>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/zod",
3
3
  "type": "module",
4
- "version": "0.0.0-next.b6be6f0",
4
+ "version": "0.0.0-next.bc564a6",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@orpc/openapi": "0.0.0-next.b6be6f0"
32
+ "@orpc/openapi": "0.0.0-next.bc564a6"
33
33
  },
34
34
  "dependencies": {
35
35
  "json-schema-typed": "^8.0.1",