-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodel.ts
64 lines (55 loc) · 1.79 KB
/
model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Component } from "./component";
import * as z from "./deps";
import { Parameter } from "./parameter";
import { Reference } from "./reference";
export type Path =
| z.ZodLiteral<any>
| z.ZodString
| z.ZodNumber
| z.ZodBoolean
| Parameter;
export type ParameterObject = z.ZodObject<{ [key: string]: Parameter }>;
export type Content =
| Reference<any>
| Component<any>
| z.ZodFirstPartySchemaTypes;
export type HttpBody = {
type: z.ZodLiteral<string>;
content: Content;
};
export type HttpBodyObject = z.ZodObject<HttpBody>;
export type HttpBodyUnion =
| HttpBodyObject
| z.ZodUnion<[HttpBodyObject, HttpBodyObject, ...HttpBodyObject[]]>
| z.ZodUndefined;
export type HttpRequest = {
name: z.ZodDefault<z.ZodLiteral<any>> | z.ZodUndefined;
method: z.ZodLiteral<string>;
path: z.ZodTuple<[Path, ...Path[]]> | z.ZodUndefined;
summary: z.ZodDefault<z.ZodLiteral<string>> | z.ZodUndefined;
tags: z.ZodDefault<z.ZodTuple<any>> | z.ZodUndefined;
query: ParameterObject;
headers: ParameterObject;
body: HttpBodyUnion;
};
export type HttpRequestObject = z.ZodObject<HttpRequest>;
export type HttpResponse = {
status: z.ZodLiteral<number | string>;
description: z.ZodLiteral<string> | z.ZodUndefined;
headers: ParameterObject | z.ZodUndefined;
body: HttpBodyUnion;
};
export type HttpResponseObject = z.ZodObject<HttpResponse>;
export type HttpResponseUnion =
| HttpResponseObject
| z.ZodUnion<
[HttpResponseObject, HttpResponseObject, ...HttpResponseObject[]]
>
| z.ZodUndefined;
export type Http = HttpRequest & {
responses: HttpResponseUnion;
};
export type HttpObject = z.ZodObject<Http>;
export type HttpOptions = [HttpObject, HttpObject, ...HttpObject[]];
export type HttpUnion = z.ZodUnion<HttpOptions>;
export type HttpSchema = HttpObject | HttpUnion;