-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathtype.ts
More file actions
149 lines (121 loc) · 3.49 KB
/
type.ts
File metadata and controls
149 lines (121 loc) · 3.49 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import type { OpenAPIV3 } from 'openapi-types';
import type {
PriorityRule,
ReactQueryMode,
SchemaObjectFormat,
SchemaObjectType,
} from './config';
export type MutuallyExclusive<T> = {
[K in keyof T]: { [P in K]: T[K] } & { [P in Exclude<keyof T, K>]?: never };
}[keyof T];
export type MutuallyExclusiveWithFallback<T, N> = {
[K in keyof T]: { [P in K]: T[K] } & { [P in Exclude<keyof T, K>]?: N };
}[keyof T];
type Modify<T, R> = Omit<T, keyof R> & R;
type ICustomBaseSchemaObject = {
type: ISchemaObjectType;
format?: ISchemaObjectFormat;
additionalProperties?: boolean | ISchemaObject;
properties?: {
[name: string]: ISchemaObject;
};
allOf?: ISchemaObject[];
oneOf?: ISchemaObject[];
anyOf?: ISchemaObject[];
'x-enum-varnames'?: string[];
'x-enum-comments'?: {
[name: string]: string;
};
'x-apifox'?: {
enumDescriptions: Record<string, string>;
};
'x-apifox-enum'?: {
value: string;
name: string;
description: string;
}[];
};
export type ArraySchemaObject = Modify<
OpenAPIV3.ArraySchemaObject,
ICustomBaseSchemaObject & {
items: ISchemaObject;
}
>;
export type BinaryArraySchemaObject = ArraySchemaObject;
export type NonArraySchemaObject = Modify<
OpenAPIV3.NonArraySchemaObject,
ICustomBaseSchemaObject
>;
export type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
export type ISchemaObject = SchemaObject | ReferenceObject;
export type ReferenceObject = OpenAPIV3.ReferenceObject;
export type PathItemObject = Modify<
OpenAPIV3.PathItemObject,
{
parameters?: (ReferenceObject | ParameterObject)[];
}
>;
export type OperationObject = Modify<
OpenAPIV3.OperationObject,
{
parameters?: (ReferenceObject | ParameterObject)[];
}
> & { 'x-run-in-apifox'?: string };
export type ComponentsObject = OpenAPIV3.ComponentsObject;
export type OpenAPIObject = OpenAPIV3.Document;
export type ParameterObject = Modify<
OpenAPIV3.ParameterObject,
{
schema?: ISchemaObject;
}
>;
export type ResponsesObject = OpenAPIV3.ResponsesObject;
export type ResponseObject = OpenAPIV3.ResponseObject & { example?: unknown };
export type RequestBodyObject = OpenAPIV3.RequestBodyObject;
export type ContentObject = {
[media: string]: OpenAPIV3.MediaTypeObject;
};
export type ISchemaObjectFormat = keyof typeof SchemaObjectFormat;
export type GenerateRegExp = {
includeTags: (string | RegExp)[];
excludeTags: (string | RegExp)[];
includePaths: (string | RegExp)[];
excludePaths: (string | RegExp)[];
};
export type ISchemaObjectType = keyof typeof SchemaObjectType;
export type IReactQueryMode = keyof typeof ReactQueryMode;
export type IPriorityRule = keyof typeof PriorityRule;
export type ReadConfigOptions = MutuallyExclusiveWithFallback<
{
fileName: string;
filePath: string;
},
undefined
> & { fallbackName: string };
export interface APIFoxBody {
scope?: {
type?: 'ALL' | 'SELECTED_TAGS';
selectedTags?: string[];
excludedByTags?: string[];
};
options?: {
includeApifoxExtensionProperties?: boolean;
addFoldersToTags?: boolean;
};
oasVersion?: '2.0' | '3.0' | '3.1';
exportFormat?: 'JSON' | 'YAML';
environmentIds?: string[];
}
export interface GetSchemaByApifoxProps
extends Pick<APIFoxBody, 'oasVersion' | 'exportFormat'>,
Pick<
APIFoxBody['options'],
'includeApifoxExtensionProperties' | 'addFoldersToTags'
> {
projectId: string;
apifoxToken: string;
locale?: string;
apifoxVersion?: string;
selectedTags?: string[];
excludedByTags?: string[];
}