fumadocs-openapi 4.4.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +113 -36
- package/dist/index.js +252 -1030
- package/dist/server/index.d.ts +211 -0
- package/dist/server/index.js +1093 -0
- package/dist/ui/client-client-CbQJObP6.js +91 -0
- package/dist/ui/index.d.ts +87 -43
- package/dist/ui/index.js +128 -185
- package/dist/ui/playground-client-W7yhm4ZD.js +1033 -0
- package/package.json +15 -10
- package/dist/chunk-N4P4W4VJ.js +0 -61
- package/dist/chunk-UG2WFM5D.js +0 -70
- package/dist/playground-GIGTWHCL.js +0 -1065
- package/dist/playground-vSsfCaVw.d.ts +0 -56
- package/dist/source/index.d.ts +0 -10
- package/dist/source/index.js +0 -39
package/dist/index.d.ts
CHANGED
|
@@ -1,60 +1,132 @@
|
|
|
1
1
|
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import Slugger from 'github-slugger';
|
|
3
|
+
import { ComponentType, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface BaseRequestField {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
interface BaseSchema {
|
|
10
|
+
description?: string;
|
|
11
|
+
isRequired: boolean;
|
|
12
|
+
}
|
|
13
|
+
type PrimitiveRequestField = BaseRequestField & PrimitiveSchema;
|
|
14
|
+
interface PrimitiveSchema extends BaseSchema {
|
|
15
|
+
type: 'boolean' | 'string' | 'number';
|
|
16
|
+
defaultValue: string;
|
|
17
|
+
}
|
|
18
|
+
interface ReferenceSchema extends BaseSchema {
|
|
19
|
+
type: 'ref';
|
|
20
|
+
schema: string;
|
|
21
|
+
}
|
|
22
|
+
interface ArraySchema extends BaseSchema {
|
|
23
|
+
type: 'array';
|
|
24
|
+
/**
|
|
25
|
+
* Reference to item schema or the schema
|
|
26
|
+
*/
|
|
27
|
+
items: string | RequestSchema;
|
|
28
|
+
}
|
|
29
|
+
interface FileSchema extends BaseSchema {
|
|
30
|
+
type: 'file';
|
|
31
|
+
}
|
|
32
|
+
interface ObjectSchema extends BaseSchema {
|
|
33
|
+
type: 'object';
|
|
34
|
+
properties: Record<string, ReferenceSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Reference to schema, or true if it's `any`
|
|
37
|
+
*/
|
|
38
|
+
additionalProperties?: boolean | string;
|
|
39
|
+
}
|
|
40
|
+
interface SwitcherSchema extends BaseSchema {
|
|
41
|
+
type: 'switcher';
|
|
42
|
+
items: Record<string, ReferenceSchema | RequestSchema>;
|
|
43
|
+
}
|
|
44
|
+
interface NullSchema extends BaseSchema {
|
|
45
|
+
type: 'null';
|
|
46
|
+
}
|
|
47
|
+
type RequestSchema = PrimitiveSchema | ArraySchema | ObjectSchema | SwitcherSchema | NullSchema | FileSchema;
|
|
48
|
+
interface APIPlaygroundProps {
|
|
49
|
+
route: string;
|
|
50
|
+
method: string;
|
|
51
|
+
bodyType: 'json' | 'form-data';
|
|
52
|
+
authorization?: PrimitiveRequestField;
|
|
53
|
+
path?: PrimitiveRequestField[];
|
|
54
|
+
query?: PrimitiveRequestField[];
|
|
55
|
+
header?: PrimitiveRequestField[];
|
|
56
|
+
body?: RequestSchema;
|
|
57
|
+
schemas: Record<string, RequestSchema>;
|
|
58
|
+
}
|
|
4
59
|
|
|
5
60
|
interface ResponsesProps {
|
|
6
61
|
items: string[];
|
|
62
|
+
children: ReactNode;
|
|
7
63
|
}
|
|
8
64
|
interface ResponseProps {
|
|
9
65
|
value: string;
|
|
66
|
+
children: ReactNode;
|
|
10
67
|
}
|
|
11
68
|
interface APIInfoProps {
|
|
12
69
|
method: string;
|
|
13
70
|
route: string;
|
|
71
|
+
children: ReactNode;
|
|
14
72
|
}
|
|
15
73
|
interface PropertyProps {
|
|
16
74
|
name: string;
|
|
17
75
|
type: string;
|
|
18
76
|
required?: boolean;
|
|
19
77
|
deprecated?: boolean;
|
|
78
|
+
children?: ReactNode;
|
|
20
79
|
}
|
|
21
80
|
interface ObjectCollapsibleProps {
|
|
22
81
|
name: string;
|
|
82
|
+
children: ReactNode;
|
|
23
83
|
}
|
|
24
84
|
interface RequestProps {
|
|
25
85
|
language: string;
|
|
26
86
|
name: string;
|
|
27
87
|
code: string;
|
|
28
88
|
}
|
|
89
|
+
interface ResponseTypeProps {
|
|
90
|
+
lang: string;
|
|
91
|
+
code: string;
|
|
92
|
+
label: string;
|
|
93
|
+
}
|
|
29
94
|
interface RootProps {
|
|
30
95
|
baseUrl?: string;
|
|
96
|
+
children: ReactNode;
|
|
31
97
|
}
|
|
32
98
|
interface Renderer {
|
|
33
|
-
Root:
|
|
34
|
-
API:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
Root: ComponentType<RootProps>;
|
|
100
|
+
API: ComponentType<{
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
}>;
|
|
103
|
+
APIInfo: ComponentType<APIInfoProps>;
|
|
104
|
+
APIExample: ComponentType<{
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
}>;
|
|
107
|
+
Responses: ComponentType<ResponsesProps>;
|
|
108
|
+
Response: ComponentType<ResponseProps>;
|
|
109
|
+
Requests: ComponentType<{
|
|
110
|
+
items: string[];
|
|
111
|
+
children: ReactNode;
|
|
112
|
+
}>;
|
|
113
|
+
Request: ComponentType<RequestProps>;
|
|
114
|
+
ResponseTypes: ComponentType<{
|
|
115
|
+
children: ReactNode;
|
|
116
|
+
}>;
|
|
117
|
+
ResponseType: ComponentType<ResponseTypeProps>;
|
|
44
118
|
/**
|
|
45
119
|
* Collapsible to show object schemas
|
|
46
120
|
*/
|
|
47
|
-
ObjectCollapsible:
|
|
48
|
-
Property:
|
|
49
|
-
APIPlayground:
|
|
121
|
+
ObjectCollapsible: ComponentType<ObjectCollapsibleProps>;
|
|
122
|
+
Property: ComponentType<PropertyProps>;
|
|
123
|
+
APIPlayground: ComponentType<APIPlaygroundProps>;
|
|
50
124
|
}
|
|
51
125
|
|
|
52
|
-
declare const defaultRenderer: Renderer;
|
|
53
|
-
|
|
54
126
|
/**
|
|
55
127
|
* Sample info of endpoint
|
|
56
128
|
*/
|
|
57
|
-
interface
|
|
129
|
+
interface EndpointSample {
|
|
58
130
|
/**
|
|
59
131
|
* Request URL, including path and query parameters
|
|
60
132
|
*/
|
|
@@ -65,13 +137,15 @@ interface Endpoint {
|
|
|
65
137
|
mediaType: string;
|
|
66
138
|
sample: unknown;
|
|
67
139
|
};
|
|
68
|
-
responses: Record<string,
|
|
69
|
-
parameters:
|
|
140
|
+
responses: Record<string, ResponseSample>;
|
|
141
|
+
parameters: ParameterSample[];
|
|
70
142
|
}
|
|
71
|
-
interface
|
|
143
|
+
interface ResponseSample {
|
|
144
|
+
mediaType: string;
|
|
145
|
+
sample: unknown;
|
|
72
146
|
schema: OpenAPIV3.SchemaObject;
|
|
73
147
|
}
|
|
74
|
-
interface
|
|
148
|
+
interface ParameterSample {
|
|
75
149
|
name: string;
|
|
76
150
|
in: string;
|
|
77
151
|
schema: OpenAPIV3.SchemaObject;
|
|
@@ -99,6 +173,7 @@ interface RenderContext {
|
|
|
99
173
|
renderer: Renderer;
|
|
100
174
|
document: OpenAPIV3.Document;
|
|
101
175
|
baseUrl: string;
|
|
176
|
+
slugger: Slugger;
|
|
102
177
|
/**
|
|
103
178
|
* Generate TypeScript definitions from response schema.
|
|
104
179
|
*
|
|
@@ -107,11 +182,11 @@ interface RenderContext {
|
|
|
107
182
|
* @param endpoint - the API endpoint
|
|
108
183
|
* @param code - status code
|
|
109
184
|
*/
|
|
110
|
-
generateTypeScriptSchema?: ((endpoint:
|
|
185
|
+
generateTypeScriptSchema?: ((endpoint: EndpointSample, code: string) => Awaitable<string>) | false;
|
|
111
186
|
/**
|
|
112
187
|
* Generate code samples for endpoint.
|
|
113
188
|
*/
|
|
114
|
-
generateCodeSamples?: (endpoint:
|
|
189
|
+
generateCodeSamples?: (endpoint: EndpointSample) => Awaitable<CodeSample[]>;
|
|
115
190
|
}
|
|
116
191
|
|
|
117
192
|
type DocumentContext = {
|
|
@@ -132,11 +207,9 @@ type DocumentContext = {
|
|
|
132
207
|
type: 'file';
|
|
133
208
|
routes: RouteInformation[];
|
|
134
209
|
};
|
|
135
|
-
interface GenerateOptions
|
|
210
|
+
interface GenerateOptions {
|
|
136
211
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* If not specified, import required components from `fumadocs-ui/components/api`.
|
|
212
|
+
* Additional imports of your MDX components.
|
|
140
213
|
*/
|
|
141
214
|
imports?: {
|
|
142
215
|
names: string[];
|
|
@@ -148,18 +221,17 @@ interface GenerateOptions extends Pick<RenderContext, 'generateCodeSamples' | 'g
|
|
|
148
221
|
* A `full: true` property will be added by default.
|
|
149
222
|
*/
|
|
150
223
|
frontmatter?: (title: string, description: string | undefined, context: DocumentContext) => Record<string, unknown>;
|
|
151
|
-
renderer?: Partial<Renderer>;
|
|
152
224
|
}
|
|
153
225
|
interface GenerateTagOutput {
|
|
154
226
|
tag: string;
|
|
155
227
|
content: string;
|
|
156
228
|
}
|
|
157
229
|
interface GenerateOperationOutput {
|
|
158
|
-
id: string;
|
|
159
230
|
content: string;
|
|
231
|
+
method: MethodInformation;
|
|
160
232
|
route: RouteInformation;
|
|
161
233
|
}
|
|
162
|
-
declare function
|
|
234
|
+
declare function generateAll(pathOrDocument: string | OpenAPIV3.Document, options?: GenerateOptions): Promise<string>;
|
|
163
235
|
declare function generateOperations(pathOrDocument: string | OpenAPIV3.Document, options?: GenerateOptions): Promise<GenerateOperationOutput[]>;
|
|
164
236
|
declare function generateTags(pathOrDocument: string | OpenAPIV3.Document, options?: GenerateOptions): Promise<GenerateTagOutput[]>;
|
|
165
237
|
|
|
@@ -187,13 +259,18 @@ interface Config extends GenerateOptions {
|
|
|
187
259
|
/**
|
|
188
260
|
* Group output using folders (Only works on `operation` mode)
|
|
189
261
|
*
|
|
262
|
+
* @deprecated Use `groupBy` instead
|
|
190
263
|
* @defaultValue false
|
|
191
264
|
*/
|
|
192
265
|
groupByFolder?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Group output using folders (Only works on `operation` mode)
|
|
268
|
+
*
|
|
269
|
+
* @defaultValue 'none'
|
|
270
|
+
*/
|
|
271
|
+
groupBy?: 'tag' | 'route' | 'none';
|
|
193
272
|
cwd?: string;
|
|
194
273
|
}
|
|
195
|
-
declare function generateFiles({ input, output, name: nameFn, per, cwd,
|
|
196
|
-
|
|
197
|
-
declare function createElement(name: string, props: object, ...child: string[]): string;
|
|
274
|
+
declare function generateFiles({ input, output, name: nameFn, per, cwd, groupBy, ...options }: Config): Promise<void>;
|
|
198
275
|
|
|
199
|
-
export { type
|
|
276
|
+
export { type Config, type DocumentContext, type GenerateOperationOutput, type GenerateOptions, type GenerateTagOutput, type MethodInformation, type RenderContext, type RouteInformation, generateAll, generateFiles, generateOperations, generateTags };
|