Skip to content

Commit 9c29000

Browse files
andenacitelliastahmer
authored andcommittedApr 19, 2023
fix: Update output corresponding to spec change
1 parent 506c26d commit 9c29000

File tree

2 files changed

+56
-116
lines changed

2 files changed

+56
-116
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { z } from "zod";
2+
3+
export const Category = z.object({ id: z.number().int(), name: z.string() }).partial();
4+
export type Category = z.infer<typeof Category>;
5+
export const Tag = z.object({ id: z.number().int(), name: z.string() }).partial();
6+
export type Tag = z.infer<typeof Tag>;
7+
export const Pet = z.object({
8+
id: z.number().int().optional(),
9+
name: z.string(),
10+
category: Category.optional(),
11+
photoUrls: z.array(z.string()),
12+
tags: z.array(Tag).optional(),
13+
status: z.enum(["available", "pending", "sold"]).optional(),
14+
});
15+
export type Pet = z.infer<typeof Pet>;
16+
export const ApiResponse = z.object({ code: z.number().int(), type: z.string(), message: z.string() }).partial();
17+
export type ApiResponse = z.infer<typeof ApiResponse>;
18+
export const Order = z
19+
.object({
20+
id: z.number().int(),
21+
petId: z.number().int(),
22+
quantity: z.number().int(),
23+
shipDate: z.string().datetime(),
24+
status: z.enum(["placed", "approved", "delivered"]),
25+
complete: z.boolean(),
26+
})
27+
.partial();
28+
export type Order = z.infer<typeof Order>;
29+
export const User = z
30+
.object({
31+
id: z.number().int(),
32+
username: z.string(),
33+
firstName: z.string(),
34+
lastName: z.string(),
35+
email: z.string(),
36+
password: z.string(),
37+
phone: z.string(),
38+
userStatus: z.number().int(),
39+
})
40+
.partial();
41+
export type User = z.infer<typeof User>;
42+
export const Address = z.object({ street: z.string(), city: z.string(), state: z.string(), zip: z.string() }).partial();
43+
export type Address = z.infer<typeof Address>;
44+
export const Customer = z.object({ id: z.number().int(), username: z.string(), address: z.array(Address) }).partial();
45+
export type Customer = z.infer<typeof Customer>;
46+
47+
export const schemas = {
48+
Category,
49+
Tag,
50+
Pet,
51+
ApiResponse,
52+
Order,
53+
User,
54+
Address,
55+
Customer,
56+
};

‎examples/export-schemas-and-types-directly/schemas.ts

-116
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.