fumadocs-openapi 10.10.0 → 10.10.1
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/css/generated/shared.css +1 -4
- package/dist/_openapi/types.d.ts +27 -1
- package/dist/index.d.ts +5 -4
- package/dist/playground/client.d.ts +1 -1
- package/dist/requests/generators/all.d.ts +1 -1
- package/dist/requests/generators/all.js +1 -0
- package/dist/types.d.ts +3 -13
- package/dist/ui/base.d.ts +1 -1
- package/dist/ui/base.js +4 -3
- package/dist/ui/client/index.d.ts +15 -10
- package/dist/ui/components/heading.js +9 -1
- package/dist/ui/contexts/api.js +1 -7
- package/dist/ui/create-client.d.ts +2 -1
- package/dist/ui/create-client.js +8 -9
- package/dist/ui/operation/request-tabs.js +4 -1
- package/dist/ui/operation/response-tabs.js +4 -1
- package/dist/ui/operation/usage-tabs/index.js +2 -8
- package/dist/utils/pages/builder.d.ts +2 -4
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/package.json +3 -4
package/css/generated/shared.css
CHANGED
|
@@ -192,6 +192,7 @@
|
|
|
192
192
|
@source inline("could");
|
|
193
193
|
@source inline("createAutoPreset");
|
|
194
194
|
@source inline("createCodeSample");
|
|
195
|
+
@source inline("createCodeUsageGeneratorRegistry");
|
|
195
196
|
@source inline("createContext");
|
|
196
197
|
@source inline("createMethod");
|
|
197
198
|
@source inline("createProxy");
|
|
@@ -397,7 +398,6 @@
|
|
|
397
398
|
@source inline("ghost");
|
|
398
399
|
@source inline("github-dark");
|
|
399
400
|
@source inline("github-light");
|
|
400
|
-
@source inline("github-slugger");
|
|
401
401
|
@source inline("given");
|
|
402
402
|
@source inline("grant_type");
|
|
403
403
|
@source inline("green");
|
|
@@ -617,7 +617,6 @@
|
|
|
617
617
|
@source inline("openApiData");
|
|
618
618
|
@source inline("openIdConnect");
|
|
619
619
|
@source inline("openapi");
|
|
620
|
-
@source inline("openapi-types");
|
|
621
620
|
@source inline("openid");
|
|
622
621
|
@source inline("operation");
|
|
623
622
|
@source inline("operationId");
|
|
@@ -923,8 +922,6 @@
|
|
|
923
922
|
@source inline("slot");
|
|
924
923
|
@source inline("slotType");
|
|
925
924
|
@source inline("slots");
|
|
926
|
-
@source inline("slug");
|
|
927
|
-
@source inline("slugger");
|
|
928
925
|
@source inline("sm");
|
|
929
926
|
@source inline("sm:flex-row");
|
|
930
927
|
@source inline("sm:gap-2");
|
package/dist/_openapi/types.d.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
//#region src/_openapi/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* These types are copied from openapi-types, with two modifications:
|
|
4
|
+
*
|
|
5
|
+
* - all attributes are optional, you can't rely on the specification for user input
|
|
6
|
+
* - extensions (basically any attributes, not only prefixed with an `x-`) are allowed
|
|
7
|
+
*
|
|
8
|
+
* We deal with user input and can't assume they really stick to any official specification.
|
|
9
|
+
*/
|
|
10
|
+
/** any other attribute, for example x-* extensions */
|
|
11
|
+
declare namespace OpenAPI {
|
|
12
|
+
type Document<T = {}> = OpenAPIV2.Document<T> | OpenAPIV3.Document<T> | OpenAPIV3_1.Document<T> | OpenAPIV3_2.Document<T>;
|
|
13
|
+
type Operation<T = {}> = OpenAPIV2.OperationObject<T> | OpenAPIV3.OperationObject<T> | OpenAPIV3_1.OperationObject<T> | OpenAPIV3_2.OperationObject<T>;
|
|
14
|
+
type Request = {
|
|
15
|
+
body?: any;
|
|
16
|
+
headers?: object;
|
|
17
|
+
params?: object;
|
|
18
|
+
query?: object;
|
|
19
|
+
};
|
|
20
|
+
type ResponseObject = OpenAPIV2.ResponseObject | OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_2.ResponseObject;
|
|
21
|
+
type HeaderObject = OpenAPIV2.HeaderObject | OpenAPIV3.HeaderObject | OpenAPIV3_1.HeaderObject | OpenAPIV3_2.HeaderObject;
|
|
22
|
+
type Parameter = OpenAPIV3_2.ReferenceObject | OpenAPIV3_2.ParameterObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ParameterObject | OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject | OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter;
|
|
23
|
+
type Parameters = (OpenAPIV3_2.ReferenceObject | OpenAPIV3_2.ParameterObject)[] | (OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ParameterObject)[] | (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[] | (OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter)[];
|
|
24
|
+
type ExampleObject = OpenAPIV2.ExampleObject | OpenAPIV3.ExampleObject | OpenAPIV3_1.ExampleObject | OpenAPIV3_2.ExampleObject;
|
|
25
|
+
type SchemaObject = OpenAPIV2.SchemaObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | OpenAPIV3_2.SchemaObject;
|
|
26
|
+
type HttpMethod = OpenAPIV2.HttpMethods | OpenAPIV3.HttpMethods | OpenAPIV3_1.HttpMethods | OpenAPIV3_2.HttpMethods;
|
|
27
|
+
}
|
|
2
28
|
declare namespace OpenAPIV3_2 {
|
|
3
29
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
4
30
|
export type PathsWebhooksComponents<T = {}> = {
|
|
@@ -877,4 +903,4 @@ type IJsonSchema = {
|
|
|
877
903
|
$ref?: string;
|
|
878
904
|
};
|
|
879
905
|
//#endregion
|
|
880
|
-
export { OpenAPIV3, OpenAPIV3_2 };
|
|
906
|
+
export { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from "./_openapi/types.js";
|
|
3
|
+
import { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./utils/pages/builder.js";
|
|
4
|
+
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
5
|
+
import { MethodInformation, RenderContext } from "./types.js";
|
|
5
6
|
import { Config, OutputFile, generateFiles, generateFilesOnly } from "./generate-file.js";
|
|
6
|
-
export {
|
|
7
|
+
export { Config, type MediaAdapter, type MethodInformation, type OpenAPI, type OpenAPIV2, type OpenAPIV3, type OpenAPIV3_1, type OpenAPIV3_2, type OperationOutput, type OutputEntry, OutputFile, type OutputGroup, type PageOutput, type PagesBuilder, type PagesBuilderConfig, type RenderContext, type SchemaToPagesOptions, type WebhookOutput, generateFiles, generateFilesOnly };
|
|
@@ -50,7 +50,7 @@ interface PlaygroundClientOptions {
|
|
|
50
50
|
* for updating values, use:
|
|
51
51
|
* - the `Custom.useController()` from `fumadocs-openapi/playground/client`.
|
|
52
52
|
*
|
|
53
|
-
* Recommended types packages: `json-schema-typed
|
|
53
|
+
* Recommended types packages: `json-schema-typed`.
|
|
54
54
|
*/
|
|
55
55
|
renderParameterField?: (fieldName: FieldKey, param: ParameterObject) => ReactNode;
|
|
56
56
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeUsageGeneratorRegistry } from "./index.js";
|
|
2
2
|
|
|
3
3
|
//#region src/requests/generators/all.d.ts
|
|
4
|
-
declare function registerDefault(registry: CodeUsageGeneratorRegistry):
|
|
4
|
+
declare function registerDefault(registry: CodeUsageGeneratorRegistry): CodeUsageGeneratorRegistry;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { registerDefault };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
2
1
|
import { InlineCodeUsageGenerator } from "./requests/generators/index.js";
|
|
3
2
|
import { boundary_d_exports } from "./ui/client/boundary.js";
|
|
4
|
-
import {
|
|
3
|
+
import { OpenAPIV3_2 } from "./_openapi/types.js";
|
|
5
4
|
import { CreateAPIPageOptions } from "./ui/base.js";
|
|
6
5
|
import { OpenAPIOptions } from "./server/index.js";
|
|
7
6
|
import { NoReference } from "./utils/schema/index.js";
|
|
8
7
|
import { DereferencedDocument } from "./utils/document/dereference.js";
|
|
9
|
-
import { ReactNode } from "react";
|
|
10
8
|
|
|
11
9
|
//#region src/types.d.ts
|
|
12
10
|
type Document = OpenAPIV3_2.Document;
|
|
@@ -17,14 +15,8 @@ type ReferenceObject = OpenAPIV3_2.ReferenceObject;
|
|
|
17
15
|
type PathItemObject = OpenAPIV3_2.PathItemObject;
|
|
18
16
|
type TagObject = OpenAPIV3_2.TagObject;
|
|
19
17
|
type ServerObject = OpenAPIV3_2.ServerObject;
|
|
20
|
-
type CallbackObject = OpenAPIV3_2.CallbackObject;
|
|
21
|
-
type ServerVariableObject = OpenAPIV3.ServerVariableObject;
|
|
22
18
|
type ResponseObject = OpenAPIV3_2.ResponseObject;
|
|
23
|
-
type OAuth2SecurityScheme = OpenAPIV3_2.OAuth2SecurityScheme;
|
|
24
19
|
type HttpMethods = OpenAPIV3_2.HttpMethods;
|
|
25
|
-
type ExampleObject = OpenAPIV3_2.ExampleObject;
|
|
26
|
-
type MediaTypeObject = OpenAPIV3_2.MediaTypeObject;
|
|
27
|
-
type RequestBodyObject = OpenAPIV3_2.RequestBodyObject;
|
|
28
20
|
type MethodInformation = NoReference<OperationObject> & {
|
|
29
21
|
method: HttpMethods;
|
|
30
22
|
'x-codeSamples'?: InlineCodeUsageGenerator[];
|
|
@@ -32,16 +24,14 @@ type MethodInformation = NoReference<OperationObject> & {
|
|
|
32
24
|
'x-exclusiveCodeSample'?: string;
|
|
33
25
|
};
|
|
34
26
|
type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
35
|
-
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions'
|
|
27
|
+
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions' | 'renderCodeBlock' | 'mediaAdapters' | 'codeUsages'>, 'renderHeading' | 'generateTypeScriptSchema'> {
|
|
36
28
|
/**
|
|
37
29
|
* dereferenced schema
|
|
38
30
|
*/
|
|
39
31
|
schema: DereferencedDocument;
|
|
40
32
|
clientBoundary: typeof boundary_d_exports;
|
|
41
|
-
mediaAdapters: Record<string, MediaAdapter>;
|
|
42
|
-
renderCodeBlock: (lang: string, code: string) => ReactNode;
|
|
43
33
|
}
|
|
44
34
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
45
35
|
type Awaitable<T> = T | Promise<T>;
|
|
46
36
|
//#endregion
|
|
47
|
-
export { Awaitable,
|
|
37
|
+
export { Awaitable, DistributiveOmit, Document, HttpMethods, MethodInformation, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, ResponseObject, SecuritySchemeObject, ServerObject, TagObject };
|
package/dist/ui/base.d.ts
CHANGED
package/dist/ui/base.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
2
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
3
|
+
import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
|
|
4
|
+
import { registerDefault } from "../requests/generators/all.js";
|
|
3
5
|
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
6
|
import { encodeInternalRef } from "../utils/schema/ref.js";
|
|
5
7
|
import { APIPage } from "./api-page.js";
|
|
6
8
|
import { pickSchema } from "../utils/schema/pick.js";
|
|
7
9
|
import { PlaygroundAuthProvider } from "./client/boundary.lazy.js";
|
|
8
|
-
import Slugger from "github-slugger";
|
|
9
10
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
import { createRehypeCode } from "fumadocs-core/mdx-plugins/rehype-code.core";
|
|
@@ -61,7 +62,6 @@ function createAPIPage(server, options) {
|
|
|
61
62
|
let processed;
|
|
62
63
|
if (typeof document === "string") processed = await server.getSchema(document);
|
|
63
64
|
else processed = document;
|
|
64
|
-
new Slugger();
|
|
65
65
|
const { ApiProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector } = await import("./client/boundary.lazy.js");
|
|
66
66
|
const ctx = {
|
|
67
67
|
schema: processed,
|
|
@@ -75,6 +75,7 @@ function createAPIPage(server, options) {
|
|
|
75
75
|
UsageTabsSelector
|
|
76
76
|
},
|
|
77
77
|
...options,
|
|
78
|
+
codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
78
79
|
mediaAdapters: {
|
|
79
80
|
...defaultAdapters,
|
|
80
81
|
...options.mediaAdapters
|
|
@@ -106,7 +107,7 @@ function createAPIPage(server, options) {
|
|
|
106
107
|
processor ??= createMarkdownProcessor();
|
|
107
108
|
return (await processor.process({ value: text })).result;
|
|
108
109
|
},
|
|
109
|
-
async renderCodeBlock(lang, code) {
|
|
110
|
+
async renderCodeBlock({ lang, code }) {
|
|
110
111
|
if (options.renderCodeBlock) return options.renderCodeBlock({
|
|
111
112
|
lang,
|
|
112
113
|
code
|
|
@@ -2,12 +2,24 @@ import { MediaAdapter } from "../../requests/media/adapter.js";
|
|
|
2
2
|
import { PlaygroundClientOptions } from "../../playground/client.js";
|
|
3
3
|
import { CodeUsageGeneratorRegistry } from "../../requests/generators/index.js";
|
|
4
4
|
import { ExampleRequestItem } from "../operation/get-example-requests.js";
|
|
5
|
-
import { FC } from "react";
|
|
5
|
+
import { ComponentProps, FC } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/ui/client/index.d.ts
|
|
8
8
|
interface APIPageClientOptions {
|
|
9
9
|
playground?: PlaygroundClientOptions;
|
|
10
|
-
operation?:
|
|
10
|
+
operation?: {
|
|
11
|
+
APIExampleSelector?: FC<{
|
|
12
|
+
items: ExampleRequestItem[];
|
|
13
|
+
value: string | undefined;
|
|
14
|
+
onValueChange: (id: string) => void;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
components?: {
|
|
18
|
+
Heading?: FC<ComponentProps<'h1'> & {
|
|
19
|
+
id: string;
|
|
20
|
+
depth: number;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
11
23
|
/**
|
|
12
24
|
* Set a prefix for `localStorage` keys.
|
|
13
25
|
*
|
|
@@ -25,13 +37,6 @@ interface APIPageClientOptions {
|
|
|
25
37
|
*/
|
|
26
38
|
codeUsages?: CodeUsageGeneratorRegistry;
|
|
27
39
|
}
|
|
28
|
-
interface OperationClientOptions {
|
|
29
|
-
APIExampleSelector?: FC<{
|
|
30
|
-
items: ExampleRequestItem[];
|
|
31
|
-
value: string | undefined;
|
|
32
|
-
onValueChange: (id: string) => void;
|
|
33
|
-
}>;
|
|
34
|
-
}
|
|
35
40
|
declare function defineClientConfig(options?: APIPageClientOptions): APIPageClientOptions;
|
|
36
41
|
//#endregion
|
|
37
|
-
export { APIPageClientOptions,
|
|
42
|
+
export { APIPageClientOptions, defineClientConfig };
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useApiContext } from "../contexts/api.js";
|
|
2
3
|
import { useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { Heading } from "fumadocs-ui/components/heading";
|
|
5
6
|
//#region src/ui/components/heading.tsx
|
|
6
7
|
function Heading$1({ id: _id, depth, ...props }) {
|
|
8
|
+
const id = useAnchorId([_id]);
|
|
9
|
+
const Component = useApiContext().client.components?.Heading;
|
|
10
|
+
if (Component) return /* @__PURE__ */ jsx(Component, {
|
|
11
|
+
id,
|
|
12
|
+
depth,
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
7
15
|
return /* @__PURE__ */ jsx(Heading, {
|
|
8
|
-
id
|
|
16
|
+
id,
|
|
9
17
|
as: `h${depth}`,
|
|
10
18
|
...props
|
|
11
19
|
});
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -21,16 +21,10 @@ function useServerContext() {
|
|
|
21
21
|
function ApiProvider({ children, shikiOptions, client, schemes }) {
|
|
22
22
|
return /* @__PURE__ */ jsx(ApiContext, {
|
|
23
23
|
value: useMemo(() => {
|
|
24
|
-
let codeUsages;
|
|
25
|
-
if (client.codeUsages) codeUsages = createCodeUsageGeneratorRegistry(client.codeUsages);
|
|
26
|
-
else {
|
|
27
|
-
codeUsages = createCodeUsageGeneratorRegistry();
|
|
28
|
-
registerDefault(codeUsages);
|
|
29
|
-
}
|
|
30
24
|
return {
|
|
31
25
|
shikiOptions,
|
|
32
26
|
client,
|
|
33
|
-
codeUsages,
|
|
27
|
+
codeUsages: client.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
34
28
|
schemes,
|
|
35
29
|
mediaAdapters: {
|
|
36
30
|
...defaultAdapters,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APIPageClientOptions } from "./client/index.js";
|
|
1
2
|
import { ApiPageProps } from "./api-page.js";
|
|
2
3
|
import { CreateAPIPageOptions } from "./base.js";
|
|
3
4
|
import { Document } from "../types.js";
|
|
@@ -11,7 +12,7 @@ interface ClientApiPagePayload {
|
|
|
11
12
|
bundled: Document;
|
|
12
13
|
proxyUrl?: string;
|
|
13
14
|
}
|
|
14
|
-
type CreateClientAPIPageOptions = Omit<
|
|
15
|
+
type CreateClientAPIPageOptions = Partial<Omit<CreateAPIPageOptions, 'generateTypeScriptSchema' | 'client'> & Omit<APIPageClientOptions, 'mediaAdapters' | 'codeUsages'>>;
|
|
15
16
|
/**
|
|
16
17
|
* Create `<APIPage />` for non-RSC environment, note that this may be unstable, and doesn't support the full set of features.
|
|
17
18
|
*/
|
package/dist/ui/create-client.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
3
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
4
|
+
import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
|
|
5
|
+
import { registerDefault } from "../requests/generators/all.js";
|
|
3
6
|
import { ClientCodeBlock, ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
7
|
import { AuthProvider } from "../playground/auth.js";
|
|
5
8
|
import { dereferenceDocument } from "../utils/document/dereference.js";
|
|
@@ -78,7 +81,9 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
78
81
|
shikiOptions,
|
|
79
82
|
generateTypeScriptDefinitions,
|
|
80
83
|
clientBoundary: boundary_exports,
|
|
84
|
+
client: options,
|
|
81
85
|
...options,
|
|
86
|
+
codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
82
87
|
mediaAdapters: {
|
|
83
88
|
...defaultAdapters,
|
|
84
89
|
...options.mediaAdapters
|
|
@@ -93,15 +98,9 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
93
98
|
processor ??= createMarkdownProcessor();
|
|
94
99
|
return processor.processSync({ value: text }).result;
|
|
95
100
|
},
|
|
96
|
-
renderCodeBlock(
|
|
97
|
-
if (options.renderCodeBlock) return options.renderCodeBlock(
|
|
98
|
-
|
|
99
|
-
code
|
|
100
|
-
});
|
|
101
|
-
return /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
102
|
-
lang,
|
|
103
|
-
code
|
|
104
|
-
});
|
|
101
|
+
renderCodeBlock(props) {
|
|
102
|
+
if (options.renderCodeBlock) return options.renderCodeBlock(props);
|
|
103
|
+
return /* @__PURE__ */ jsx(ClientCodeBlock, { ...props });
|
|
105
104
|
}
|
|
106
105
|
}), [payload.proxyUrl, processed]);
|
|
107
106
|
return /* @__PURE__ */ jsx(ClientCodeBlockProvider, {
|
|
@@ -73,7 +73,10 @@ function RequestTabsItem({ item, ctx }) {
|
|
|
73
73
|
value: k,
|
|
74
74
|
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
75
75
|
className: "prose-no-margin",
|
|
76
|
-
children: ctx.renderCodeBlock(
|
|
76
|
+
children: ctx.renderCodeBlock({
|
|
77
|
+
lang: "json",
|
|
78
|
+
code: JSON.stringify(data, null, 2)
|
|
79
|
+
})
|
|
77
80
|
})]
|
|
78
81
|
}, k);
|
|
79
82
|
})
|
|
@@ -45,7 +45,10 @@ function ResponseTabs({ operation, ctx }) {
|
|
|
45
45
|
}
|
|
46
46
|
function renderResponseTabsDefault(tabs, ctx) {
|
|
47
47
|
function renderExampleContent(example) {
|
|
48
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description && ctx.renderMarkdown(example.description), ctx.renderCodeBlock(
|
|
48
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description && ctx.renderMarkdown(example.description), ctx.renderCodeBlock({
|
|
49
|
+
lang: "json",
|
|
50
|
+
code: JSON.stringify(example.sample, null, 2)
|
|
51
|
+
})] });
|
|
49
52
|
}
|
|
50
53
|
return /* @__PURE__ */ jsx(Tabs, {
|
|
51
54
|
groupId: "fumadocs_openapi_responses",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createCodeUsageGeneratorRegistry } from "../../../requests/generators/index.js";
|
|
2
|
-
import { registerDefault } from "../../../requests/generators/all.js";
|
|
3
2
|
import { ResponseTabs } from "../response-tabs.js";
|
|
4
3
|
import { useMemo } from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -37,13 +36,8 @@ function UsageTabs({ method, ctx }) {
|
|
|
37
36
|
});
|
|
38
37
|
};
|
|
39
38
|
const registry = useMemo(() => {
|
|
40
|
-
|
|
41
|
-
if (ctx.
|
|
42
|
-
else {
|
|
43
|
-
registry = createCodeUsageGeneratorRegistry();
|
|
44
|
-
registerDefault(registry);
|
|
45
|
-
}
|
|
46
|
-
for (const gen of ctx.generateCodeSamples?.(method) ?? []) registry.addInline(gen);
|
|
39
|
+
const registry = createCodeUsageGeneratorRegistry(ctx.codeUsages);
|
|
40
|
+
if (ctx.generateCodeSamples) for (const gen of ctx.generateCodeSamples(method)) registry.addInline(gen);
|
|
47
41
|
if (method["x-codeSamples"]) for (const sample of method["x-codeSamples"]) registry.addInline(sample);
|
|
48
42
|
return registry;
|
|
49
43
|
}, [ctx, method]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OperationItem, WebhookItem } from "../../ui/api-page.js";
|
|
2
2
|
import { OperationObject, PathItemObject, TagObject } from "../../types.js";
|
|
3
3
|
import { NoReference } from "../schema/index.js";
|
|
4
4
|
import { DereferencedDocument } from "../document/dereference.js";
|
|
@@ -82,7 +82,5 @@ interface ExtractedInfo {
|
|
|
82
82
|
tags?: string[];
|
|
83
83
|
})[];
|
|
84
84
|
}
|
|
85
|
-
declare function fromSchema(schemaId: string, processed: DereferencedDocument, config: PagesBuilderConfig): OutputEntry[];
|
|
86
|
-
declare function getPageProps(entry: PageOutput | OperationOutput | WebhookOutput): ApiPageProps;
|
|
87
85
|
//#endregion
|
|
88
|
-
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput
|
|
86
|
+
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput };
|
|
@@ -66,6 +66,5 @@ interface BaseConfig {
|
|
|
66
66
|
*/
|
|
67
67
|
slugify?: (name: string) => string;
|
|
68
68
|
}
|
|
69
|
-
declare function createAutoPreset(options: SchemaToPagesOptions): PagesBuilderConfig;
|
|
70
69
|
//#endregion
|
|
71
|
-
export { SchemaToPagesOptions
|
|
70
|
+
export { SchemaToPagesOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "10.10.
|
|
3
|
+
"version": "10.10.1",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
45
45
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
46
46
|
"@radix-ui/react-select": "^2.2.6",
|
|
47
|
-
"@radix-ui/react-slot": "^1.2.4",
|
|
48
47
|
"chokidar": "^5.0.0",
|
|
49
48
|
"class-variance-authority": "^0.7.1",
|
|
50
49
|
"github-slugger": "^2.0.0",
|
|
@@ -73,8 +72,8 @@
|
|
|
73
72
|
"tsdown": "0.22.0",
|
|
74
73
|
"xml-js": "^1.6.11",
|
|
75
74
|
"fumadocs-core": "16.9.3",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
75
|
+
"fumadocs-ui": "16.9.3",
|
|
76
|
+
"tsconfig": "0.0.0"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
80
79
|
"@scalar/api-client-react": "^2.0.20",
|