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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import { ComponentType, ReactNode, FC } from 'react';
|
|
3
|
+
import Slugger from 'github-slugger';
|
|
4
|
+
import { BuildPageTreeOptions } from 'fumadocs-core/source';
|
|
5
|
+
|
|
6
|
+
interface BaseRequestField {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
interface BaseSchema {
|
|
11
|
+
description?: string;
|
|
12
|
+
isRequired: boolean;
|
|
13
|
+
}
|
|
14
|
+
type PrimitiveRequestField = BaseRequestField & PrimitiveSchema;
|
|
15
|
+
interface PrimitiveSchema extends BaseSchema {
|
|
16
|
+
type: 'boolean' | 'string' | 'number';
|
|
17
|
+
defaultValue: string;
|
|
18
|
+
}
|
|
19
|
+
interface ReferenceSchema extends BaseSchema {
|
|
20
|
+
type: 'ref';
|
|
21
|
+
schema: string;
|
|
22
|
+
}
|
|
23
|
+
interface ArraySchema extends BaseSchema {
|
|
24
|
+
type: 'array';
|
|
25
|
+
/**
|
|
26
|
+
* Reference to item schema or the schema
|
|
27
|
+
*/
|
|
28
|
+
items: string | RequestSchema;
|
|
29
|
+
}
|
|
30
|
+
interface FileSchema extends BaseSchema {
|
|
31
|
+
type: 'file';
|
|
32
|
+
}
|
|
33
|
+
interface ObjectSchema extends BaseSchema {
|
|
34
|
+
type: 'object';
|
|
35
|
+
properties: Record<string, ReferenceSchema>;
|
|
36
|
+
/**
|
|
37
|
+
* Reference to schema, or true if it's `any`
|
|
38
|
+
*/
|
|
39
|
+
additionalProperties?: boolean | string;
|
|
40
|
+
}
|
|
41
|
+
interface SwitcherSchema extends BaseSchema {
|
|
42
|
+
type: 'switcher';
|
|
43
|
+
items: Record<string, ReferenceSchema | RequestSchema>;
|
|
44
|
+
}
|
|
45
|
+
interface NullSchema extends BaseSchema {
|
|
46
|
+
type: 'null';
|
|
47
|
+
}
|
|
48
|
+
type RequestSchema = PrimitiveSchema | ArraySchema | ObjectSchema | SwitcherSchema | NullSchema | FileSchema;
|
|
49
|
+
interface APIPlaygroundProps {
|
|
50
|
+
route: string;
|
|
51
|
+
method: string;
|
|
52
|
+
bodyType: 'json' | 'form-data';
|
|
53
|
+
authorization?: PrimitiveRequestField;
|
|
54
|
+
path?: PrimitiveRequestField[];
|
|
55
|
+
query?: PrimitiveRequestField[];
|
|
56
|
+
header?: PrimitiveRequestField[];
|
|
57
|
+
body?: RequestSchema;
|
|
58
|
+
schemas: Record<string, RequestSchema>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface ResponsesProps {
|
|
62
|
+
items: string[];
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
}
|
|
65
|
+
interface ResponseProps {
|
|
66
|
+
value: string;
|
|
67
|
+
children: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
interface APIInfoProps {
|
|
70
|
+
method: string;
|
|
71
|
+
route: string;
|
|
72
|
+
children: ReactNode;
|
|
73
|
+
}
|
|
74
|
+
interface PropertyProps {
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
required?: boolean;
|
|
78
|
+
deprecated?: boolean;
|
|
79
|
+
children?: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
interface ObjectCollapsibleProps {
|
|
82
|
+
name: string;
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
}
|
|
85
|
+
interface RequestProps {
|
|
86
|
+
language: string;
|
|
87
|
+
name: string;
|
|
88
|
+
code: string;
|
|
89
|
+
}
|
|
90
|
+
interface ResponseTypeProps {
|
|
91
|
+
lang: string;
|
|
92
|
+
code: string;
|
|
93
|
+
label: string;
|
|
94
|
+
}
|
|
95
|
+
interface RootProps {
|
|
96
|
+
baseUrl?: string;
|
|
97
|
+
children: ReactNode;
|
|
98
|
+
}
|
|
99
|
+
interface Renderer {
|
|
100
|
+
Root: ComponentType<RootProps>;
|
|
101
|
+
API: ComponentType<{
|
|
102
|
+
children: ReactNode;
|
|
103
|
+
}>;
|
|
104
|
+
APIInfo: ComponentType<APIInfoProps>;
|
|
105
|
+
APIExample: ComponentType<{
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
}>;
|
|
108
|
+
Responses: ComponentType<ResponsesProps>;
|
|
109
|
+
Response: ComponentType<ResponseProps>;
|
|
110
|
+
Requests: ComponentType<{
|
|
111
|
+
items: string[];
|
|
112
|
+
children: ReactNode;
|
|
113
|
+
}>;
|
|
114
|
+
Request: ComponentType<RequestProps>;
|
|
115
|
+
ResponseTypes: ComponentType<{
|
|
116
|
+
children: ReactNode;
|
|
117
|
+
}>;
|
|
118
|
+
ResponseType: ComponentType<ResponseTypeProps>;
|
|
119
|
+
/**
|
|
120
|
+
* Collapsible to show object schemas
|
|
121
|
+
*/
|
|
122
|
+
ObjectCollapsible: ComponentType<ObjectCollapsibleProps>;
|
|
123
|
+
Property: ComponentType<PropertyProps>;
|
|
124
|
+
APIPlayground: ComponentType<APIPlaygroundProps>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sample info of endpoint
|
|
129
|
+
*/
|
|
130
|
+
interface EndpointSample {
|
|
131
|
+
/**
|
|
132
|
+
* Request URL, including path and query parameters
|
|
133
|
+
*/
|
|
134
|
+
url: string;
|
|
135
|
+
method: string;
|
|
136
|
+
body?: {
|
|
137
|
+
schema: OpenAPIV3.SchemaObject;
|
|
138
|
+
mediaType: string;
|
|
139
|
+
sample: unknown;
|
|
140
|
+
};
|
|
141
|
+
responses: Record<string, ResponseSample>;
|
|
142
|
+
parameters: ParameterSample[];
|
|
143
|
+
}
|
|
144
|
+
interface ResponseSample {
|
|
145
|
+
mediaType: string;
|
|
146
|
+
sample: unknown;
|
|
147
|
+
schema: OpenAPIV3.SchemaObject;
|
|
148
|
+
}
|
|
149
|
+
interface ParameterSample {
|
|
150
|
+
name: string;
|
|
151
|
+
in: string;
|
|
152
|
+
schema: OpenAPIV3.SchemaObject;
|
|
153
|
+
sample: unknown;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface CodeSample {
|
|
157
|
+
lang: string;
|
|
158
|
+
label: string;
|
|
159
|
+
source: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type Awaitable<T> = T | Promise<T>;
|
|
163
|
+
interface RenderContext {
|
|
164
|
+
renderer: Renderer;
|
|
165
|
+
document: OpenAPIV3.Document;
|
|
166
|
+
baseUrl: string;
|
|
167
|
+
slugger: Slugger;
|
|
168
|
+
/**
|
|
169
|
+
* Generate TypeScript definitions from response schema.
|
|
170
|
+
*
|
|
171
|
+
* Pass `false` to disable it.
|
|
172
|
+
*
|
|
173
|
+
* @param endpoint - the API endpoint
|
|
174
|
+
* @param code - status code
|
|
175
|
+
*/
|
|
176
|
+
generateTypeScriptSchema?: ((endpoint: EndpointSample, code: string) => Awaitable<string>) | false;
|
|
177
|
+
/**
|
|
178
|
+
* Generate code samples for endpoint.
|
|
179
|
+
*/
|
|
180
|
+
generateCodeSamples?: (endpoint: EndpointSample) => Awaitable<CodeSample[]>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface ApiPageProps {
|
|
184
|
+
/**
|
|
185
|
+
* An array of operation
|
|
186
|
+
*/
|
|
187
|
+
operations: {
|
|
188
|
+
path: string;
|
|
189
|
+
method: OpenAPIV3.HttpMethods;
|
|
190
|
+
}[];
|
|
191
|
+
hasHead: boolean;
|
|
192
|
+
ctx: RenderContext;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface OpenAPIOptions extends Pick<RenderContext, 'generateCodeSamples' | 'generateTypeScriptSchema'> {
|
|
196
|
+
documentOrPath: string | OpenAPIV3.Document;
|
|
197
|
+
renderer?: Partial<Renderer>;
|
|
198
|
+
}
|
|
199
|
+
interface OpenAPIServer {
|
|
200
|
+
APIPage: FC<Omit<ApiPageProps, 'ctx'>>;
|
|
201
|
+
}
|
|
202
|
+
declare function createOpenAPI(options: OpenAPIOptions): OpenAPIServer;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Source API Integration
|
|
206
|
+
*
|
|
207
|
+
* Add this to page tree builder options
|
|
208
|
+
*/
|
|
209
|
+
declare const attachFile: BuildPageTreeOptions['attachFile'];
|
|
210
|
+
|
|
211
|
+
export { type OpenAPIOptions, type OpenAPIServer, attachFile, createOpenAPI };
|