fumadocs-openapi 12.5.5 → 12.5.7
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 -1
- package/dist/.translations/index.d.ts +6 -3
- package/dist/.translations/keys.js +6 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/generate-file.d.ts +1 -3
- package/dist/generate-file.js +3 -3
- package/dist/i18n.d.ts +1 -3
- package/dist/i18n.js +1 -2
- package/dist/index.browser.d.ts +0 -2
- package/dist/index.browser.js +1 -2
- package/dist/node_modules/.pnpm/fast-content-type-parse@4.0.1/node_modules/fast-content-type-parse/index.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/array-helper.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/js2xml.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/options-helper.js +1 -2
- package/dist/operation.d.ts +1 -3
- package/dist/operation.js +3 -4
- package/dist/packages/shared-api/dist/.translations/index.d.ts +2 -5
- package/dist/packages/shared-api/dist/.translations/keys.js +2 -2
- package/dist/packages/shared-api/dist/auto-anchor/index.js +1 -2
- package/dist/packages/shared-api/dist/codegen.d.ts +0 -3
- package/dist/packages/shared-api/dist/codegen.js +1 -2
- package/dist/packages/shared-api/dist/components/badge.js +1 -2
- package/dist/packages/shared-api/dist/components/collapsible.js +1 -2
- package/dist/packages/shared-api/dist/components/copy-typescript.js +1 -2
- package/dist/packages/shared-api/dist/components/defaults.d.ts +1 -4
- package/dist/packages/shared-api/dist/components/defaults.js +1 -2
- package/dist/packages/shared-api/dist/components/dialog.js +1 -2
- package/dist/packages/shared-api/dist/components/example.js +3 -3
- package/dist/packages/shared-api/dist/components/playground/fields.js +28 -10
- package/dist/packages/shared-api/dist/components/playground/json-editor.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/panels.js +2 -3
- package/dist/packages/shared-api/dist/components/playground/param-input.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/result.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/schema.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/server-select.js +2 -3
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +1 -4
- package/dist/packages/shared-api/dist/components/schema/client.js +3 -2
- package/dist/packages/shared-api/dist/components/schema/index.d.ts +0 -3
- package/dist/packages/shared-api/dist/components/schema/index.js +1 -2
- package/dist/packages/shared-api/dist/components/segmented.js +1 -2
- package/dist/packages/shared-api/dist/components/select-tab.js +1 -2
- package/dist/packages/shared-api/dist/components/select.js +1 -2
- package/dist/packages/shared-api/dist/components/spinner.js +1 -2
- package/dist/packages/shared-api/dist/i18n.js +1 -2
- package/dist/packages/shared-api/dist/source.d.ts +1 -4
- package/dist/packages/shared-api/dist/source.js +1 -2
- package/dist/packages/shared-api/dist/utils/document-cache.js +1 -2
- package/dist/packages/shared-api/dist/utils/id-to-title.js +1 -2
- package/dist/packages/shared-api/dist/utils/is-plain-object.js +1 -2
- package/dist/packages/shared-api/dist/utils/url.js +1 -2
- package/dist/packages/shared-api/dist/utils/use-query.js +1 -2
- package/dist/packages/shared-api/dist/utils/use-server-store.js +1 -2
- package/dist/playground/auth.d.ts +8 -8
- package/dist/playground/auth.js +90 -59
- package/dist/playground/fetcher.d.ts +1 -3
- package/dist/playground/fetcher.js +1 -2
- package/dist/playground/use-playground.d.ts +1 -3
- package/dist/playground/use-playground.js +3 -4
- package/dist/requests/generators/all.d.ts +1 -3
- package/dist/requests/generators/all.js +1 -2
- package/dist/requests/generators/csharp.d.ts +1 -3
- package/dist/requests/generators/csharp.js +1 -2
- package/dist/requests/generators/curl.d.ts +1 -3
- package/dist/requests/generators/curl.js +1 -2
- package/dist/requests/generators/go.d.ts +1 -3
- package/dist/requests/generators/go.js +1 -2
- package/dist/requests/generators/index.d.ts +1 -3
- package/dist/requests/generators/index.js +1 -2
- package/dist/requests/generators/java.d.ts +1 -3
- package/dist/requests/generators/java.js +1 -2
- package/dist/requests/generators/javascript.d.ts +1 -3
- package/dist/requests/generators/javascript.js +1 -2
- package/dist/requests/generators/python.d.ts +1 -3
- package/dist/requests/generators/python.js +1 -2
- package/dist/requests/generators/rust.d.ts +1 -3
- package/dist/requests/generators/rust.js +1 -2
- package/dist/requests/media/adapter.d.ts +0 -2
- package/dist/requests/media/adapter.js +1 -2
- package/dist/requests/media/encode.d.ts +1 -3
- package/dist/requests/media/encode.js +1 -2
- package/dist/requests/media/resolve-adapter.d.ts +1 -3
- package/dist/requests/media/resolve-adapter.js +1 -2
- package/dist/requests/string-utils.js +1 -2
- package/dist/requests/types.d.ts +1 -3
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.js +1 -2
- package/dist/server/oauth.d.ts +1 -3
- package/dist/server/oauth.js +7 -11
- package/dist/server/proxy.d.ts +0 -2
- package/dist/server/proxy.js +8 -4
- package/dist/types/openapi.d.ts +1 -3
- package/dist/types.d.ts +1 -3
- package/dist/ui/base.d.ts +1 -3
- package/dist/ui/base.js +1 -2
- package/dist/ui/components/codeblock.js +1 -2
- package/dist/ui/components/endpoint.js +1 -2
- package/dist/ui/components/heading.js +1 -2
- package/dist/ui/components/markdown.js +1 -2
- package/dist/ui/components/method-label.js +1 -2
- package/dist/ui/components/schema.js +1 -2
- package/dist/ui/index.d.ts +0 -2
- package/dist/ui/index.js +1 -2
- package/dist/ui/operation/index.js +29 -16
- package/dist/ui/operation/usage-tabs.js +13 -6
- package/dist/ui/playground/client.d.ts +5 -4
- package/dist/ui/playground/client.js +5 -6
- package/dist/ui/playground/components/auth.js +4 -5
- package/dist/ui/playground/components/request-panel.d.ts +8 -0
- package/dist/ui/playground/components/request-panel.js +17 -11
- package/dist/ui/playground/components/response-panel.js +1 -2
- package/dist/ui/playground/components/result-display.d.ts +1 -3
- package/dist/ui/playground/components/result-display.js +1 -2
- package/dist/ui/playground/components/server-select.js +1 -2
- package/dist/ui/playground/components/url-bar.js +1 -2
- package/dist/ui/scalar/client.js +1 -2
- package/dist/ui/scalar/index.d.ts +1 -3
- package/dist/ui/scalar/index.js +1 -2
- package/dist/utils/create-page.d.ts +1 -3
- package/dist/utils/create-page.js +2 -4
- package/dist/utils/document/dereference.d.ts +1 -3
- package/dist/utils/document/dereference.js +1 -2
- package/dist/utils/document/load.js +1 -2
- package/dist/utils/get-example-requests.js +2 -3
- package/dist/utils/pages/builder.d.ts +0 -2
- package/dist/utils/pages/builder.js +1 -2
- package/dist/utils/pages/preset-auto.d.ts +0 -2
- package/dist/utils/pages/preset-auto.js +1 -2
- package/dist/utils/pages/to-static-data.d.ts +1 -3
- package/dist/utils/pages/to-static-data.js +1 -2
- package/dist/utils/pages/to-text.d.ts +1 -3
- package/dist/utils/pages/to-text.js +1 -2
- package/dist/utils/schema.js +1 -2
- package/dist/utils/use-server.d.ts +2 -4
- package/dist/utils/use-server.js +3 -3
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@ import { SendButton } from "../../../packages/shared-api/dist/components/playgro
|
|
|
5
5
|
import { ParamInput } from "../../../packages/shared-api/dist/components/playground/param-input.js";
|
|
6
6
|
import ServerSelect from "./server-select.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/ui/playground/components/url-bar.tsx
|
|
9
9
|
function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
10
10
|
return /* @__PURE__ */ jsxs("div", {
|
|
11
11
|
className: "flex items-center gap-2",
|
|
@@ -34,5 +34,4 @@ function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
|
34
34
|
}), /* @__PURE__ */ jsx(SendButton, { sending: loading })]
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { UrlBar };
|
package/dist/ui/scalar/client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
|
9
9
|
import { useApiClient } from "@scalar/api-client-react";
|
|
10
10
|
import { useTheme } from "fumadocs-ui/provider/base";
|
|
11
11
|
import "@scalar/api-client-react/style.css";
|
|
12
|
-
|
|
12
|
+
// src/ui/scalar/client.tsx
|
|
13
13
|
const noop = () => () => {};
|
|
14
14
|
function ScalarPlayground({ path, method }) {
|
|
15
15
|
const { resolvedTheme } = useTheme();
|
|
@@ -43,5 +43,4 @@ function ScalarPlayground({ path, method }) {
|
|
|
43
43
|
]
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { ScalarPlayground as default };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CreateOpenAPIPageOptions } from "../index.js";
|
|
2
|
-
//#region src/ui/scalar/index.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Enable Scalar for API playgrounds by wrapping your options inside.
|
|
5
4
|
*
|
|
6
5
|
* Requires `@scalar/api-client-react` to be installed, it imports the styles automatically.
|
|
7
6
|
*/
|
|
8
|
-
export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
|
package/dist/ui/scalar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { lazy } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/ui/scalar/index.tsx
|
|
5
5
|
const Client = lazy(() => import("./client.js"));
|
|
6
6
|
/**
|
|
7
7
|
* Enable Scalar for API playgrounds by wrapping your options inside.
|
|
@@ -22,5 +22,4 @@ function withScalar(options = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { withScalar };
|
|
@@ -11,7 +11,6 @@ import { FC, ReactNode } from "react";
|
|
|
11
11
|
import { JsonSchema } from "@fumadocs/json-schema";
|
|
12
12
|
import { ShikiFactory } from "fumadocs-core/highlight/shiki";
|
|
13
13
|
import { Highlighter } from "fumadocs-core/highlight";
|
|
14
|
-
//#region src/utils/create-page.d.ts
|
|
15
14
|
/** components the UI renders through, so a page can replace them */
|
|
16
15
|
export interface OpenAPIComponents extends PageComponents {
|
|
17
16
|
SchemaUI: FC<SchemaUIOptions>;
|
|
@@ -216,5 +215,4 @@ export declare function useTypeScriptDefinitions(schema: JsonSchema | undefined,
|
|
|
216
215
|
* `createOpenAPIRenderer()` with nothing built in: it highlights through the `highlighter` you pass,
|
|
217
216
|
* and generates code usages and TypeScript definitions only when you pass them.
|
|
218
217
|
*/
|
|
219
|
-
export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
|
|
220
|
-
//#endregion
|
|
218
|
+
export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
|
|
@@ -6,12 +6,11 @@ import { registerDefault } from "../requests/generators/all.js";
|
|
|
6
6
|
import { createDocumentCache } from "../packages/shared-api/dist/utils/document-cache.js";
|
|
7
7
|
import { createPageComponents, defaultShikiOptions, resolveHighlighter } from "../packages/shared-api/dist/components/defaults.js";
|
|
8
8
|
import { ServerProvider } from "./use-server.js";
|
|
9
|
-
import { PlaygroundAuthProvider } from "../playground/auth.js";
|
|
10
9
|
import { createContext, use, useMemo } from "react";
|
|
11
10
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
12
11
|
import { generate } from "@fumari/json-schema-ts";
|
|
13
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
|
|
13
|
+
// src/utils/create-page.tsx
|
|
15
14
|
const OpenAPIContext = createContext(null);
|
|
16
15
|
const ComponentsContext = createContext(null);
|
|
17
16
|
const OptionsContext = createContext(null);
|
|
@@ -109,7 +108,7 @@ function OpenAPIProvider({ document: input, mediaAdapters, codeUsages, generateC
|
|
|
109
108
|
children: /* @__PURE__ */ jsx(ServerProvider, {
|
|
110
109
|
servers: runtime.doc.dereferenced.servers,
|
|
111
110
|
storageKeyPrefix: runtime.storageKeyPrefix,
|
|
112
|
-
children
|
|
111
|
+
children
|
|
113
112
|
})
|
|
114
113
|
})
|
|
115
114
|
})
|
|
@@ -230,5 +229,4 @@ function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }) {
|
|
|
230
229
|
function DefaultLayout({ operations, webhooks }) {
|
|
231
230
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [operations?.map((item) => item.children), webhooks?.map((item) => item.children)] });
|
|
232
231
|
}
|
|
233
|
-
//#endregion
|
|
234
232
|
export { createOpenAPIBaseRenderer, createRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Document } from "../../types.js";
|
|
2
2
|
import { DereferencedShallow } from "@fumadocs/json-schema";
|
|
3
|
-
//#region src/utils/document/dereference.d.ts
|
|
4
3
|
export interface DereferencedDocument {
|
|
5
4
|
/**
|
|
6
5
|
* document wrapped in a magic proxy (`@scalar/json-magic`).
|
|
@@ -15,5 +14,4 @@ export interface DereferencedDocument {
|
|
|
15
14
|
*/
|
|
16
15
|
resolve: <T>(node: T) => DereferencedShallow<T>;
|
|
17
16
|
bundled: Document;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMagicProxy } from "@scalar/json-magic/magic-proxy";
|
|
2
2
|
import { dereference } from "@fumadocs/json-schema";
|
|
3
|
-
|
|
3
|
+
// src/utils/document/dereference.ts
|
|
4
4
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
function dereferenceBundledDocument(bundled) {
|
|
6
6
|
const cached = cache.get(bundled);
|
|
@@ -15,5 +15,4 @@ function dereferenceBundledDocument(bundled) {
|
|
|
15
15
|
cache.set(bundled, doc);
|
|
16
16
|
return doc;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { dereferenceBundledDocument };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { upgrade } from "@scalar/openapi-upgrader";
|
|
2
2
|
import { bundle } from "@fumadocs/json-schema/bundle";
|
|
3
|
-
|
|
3
|
+
// src/utils/document/load.ts
|
|
4
4
|
/**
|
|
5
5
|
* Process input document to a Fumadocs OpenAPI compatible format
|
|
6
6
|
*/
|
|
@@ -11,5 +11,4 @@ async function loadDocument(input) {
|
|
|
11
11
|
throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { loadDocument };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { encodeRequestData } from "../requests/media/encode.js";
|
|
2
1
|
import { getExampleValue, getPreferredType, pickExample } from "./schema.js";
|
|
2
|
+
import { encodeRequestData } from "../requests/media/encode.js";
|
|
3
3
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
4
4
|
import { dereference, sample } from "@fumadocs/json-schema";
|
|
5
|
-
|
|
5
|
+
// src/utils/get-example-requests.ts
|
|
6
6
|
function getExampleRequests({ path, method, mediaAdapters, operation, parameters }) {
|
|
7
7
|
const requestBody = dereference(operation.requestBody);
|
|
8
8
|
const media = requestBody?.content ? getPreferredType(requestBody.content) : null;
|
|
@@ -91,5 +91,4 @@ function getRequestData({ method, path, parameters, sampleKey, body }) {
|
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
}
|
|
94
|
-
//#endregion
|
|
95
94
|
export { getExampleRequests };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Document, HttpMethods, OperationObject, PathItemObject, TagObject } from "../../types.js";
|
|
2
2
|
import { DereferencedShallow } from "@fumadocs/json-schema";
|
|
3
|
-
//#region src/utils/pages/builder.d.ts
|
|
4
3
|
interface BaseEntry {
|
|
5
4
|
path: string;
|
|
6
5
|
schemaId: string;
|
|
@@ -123,5 +122,4 @@ export type OpenAPIPageProps_Preloaded = GeneratedPageProps & {
|
|
|
123
122
|
proxyUrl?: string;
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
|
-
//#endregion
|
|
127
125
|
export {};
|
|
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
|
|
|
2
2
|
import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
|
|
3
3
|
import { getTagDisplayName, methodKeys } from "../schema.js";
|
|
4
4
|
import { dereference } from "@fumadocs/json-schema";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/builder.ts
|
|
6
6
|
function fromSchema(schemaId, bundled, config) {
|
|
7
7
|
const files = [];
|
|
8
8
|
const { toPages } = config;
|
|
@@ -112,5 +112,4 @@ function getPageProps(entry) {
|
|
|
112
112
|
webhooks: entry.webhooks
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
115
|
export { fromSchema, getPageProps };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DistributiveOmit } from "../../types.js";
|
|
2
2
|
import { OperationOutput, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./builder.js";
|
|
3
|
-
//#region src/utils/pages/preset-auto.d.ts
|
|
4
3
|
interface OperationConfig extends BaseConfig {
|
|
5
4
|
/**
|
|
6
5
|
* Generate a page for each API endpoint/operation (default).
|
|
@@ -64,5 +63,4 @@ interface BaseConfig {
|
|
|
64
63
|
*/
|
|
65
64
|
slugify?: (name: string) => string;
|
|
66
65
|
}
|
|
67
|
-
//#endregion
|
|
68
66
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getTagDisplayName } from "../schema.js";
|
|
2
2
|
import { dereference } from "@fumadocs/json-schema";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/utils/pages/preset-auto.ts
|
|
5
5
|
function createAutoPreset(options) {
|
|
6
6
|
if (options.per === "custom") return options;
|
|
7
7
|
const { slugify = (s) => {
|
|
@@ -208,5 +208,4 @@ function createAutoPreset(options) {
|
|
|
208
208
|
for (const entry of root) builder.create(entry);
|
|
209
209
|
} };
|
|
210
210
|
}
|
|
211
|
-
//#endregion
|
|
212
211
|
export { createAutoPreset };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import "./builder.js";
|
|
2
2
|
import { TOCItemType } from "fumadocs-core/toc";
|
|
3
3
|
import "fumadocs-core/mdx-plugins";
|
|
4
|
-
//#region src/utils/pages/to-static-data.d.ts
|
|
5
4
|
/** the `_openapi` data of pages */
|
|
6
5
|
export interface InternalOpenAPIMeta {
|
|
7
6
|
method?: string;
|
|
8
7
|
webhook?: boolean;
|
|
9
8
|
deprecated?: boolean;
|
|
10
9
|
preload?: string[];
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
10
|
+
}
|
|
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
|
|
|
2
2
|
import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
|
|
3
3
|
import { dereference } from "@fumadocs/json-schema";
|
|
4
4
|
import Slugger from "github-slugger";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/to-static-data.ts
|
|
6
6
|
function toStaticData(page, doc) {
|
|
7
7
|
const proxied = dereferenceBundledDocument(doc).dereferenced;
|
|
8
8
|
const slugger = new Slugger();
|
|
@@ -45,5 +45,4 @@ function toStaticData(page, doc) {
|
|
|
45
45
|
structuredData
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { toStaticData };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TagObject } from "../../types.js";
|
|
2
2
|
import "./builder.js";
|
|
3
|
-
//#region src/utils/pages/to-text.d.ts
|
|
4
3
|
export interface PagesToTextOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Additional imports of your MDX components.
|
|
@@ -40,5 +39,4 @@ export type DocumentContext = {
|
|
|
40
39
|
type: 'operation';
|
|
41
40
|
} | {
|
|
42
41
|
type: 'file';
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
42
|
+
};
|
|
@@ -2,7 +2,7 @@ import { doubleQuote, jsxString } from "../../requests/string-utils.js";
|
|
|
2
2
|
import { getPageProps } from "./builder.js";
|
|
3
3
|
import { toStaticData } from "./to-static-data.js";
|
|
4
4
|
import { stringify } from "yaml";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/to-text.ts
|
|
6
6
|
function toText(entry, doc, options = {}) {
|
|
7
7
|
const { frontmatter, includeDescription = false } = options;
|
|
8
8
|
const extend = frontmatter?.(entry.info.title, entry.info.description, entry.type === "page" ? entry.tag ? {
|
|
@@ -70,5 +70,4 @@ function pageContent({ showTitle, showDescription, document, webhooks, operation
|
|
|
70
70
|
);
|
|
71
71
|
}`;
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
73
|
export { generateDocument, toText };
|
package/dist/utils/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { idToTitle } from "../packages/shared-api/dist/utils/id-to-title.js";
|
|
2
2
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
3
3
|
import { dereference } from "@fumadocs/json-schema";
|
|
4
|
-
|
|
4
|
+
// src/utils/schema.ts
|
|
5
5
|
const methodKeys = [
|
|
6
6
|
"get",
|
|
7
7
|
"post",
|
|
@@ -39,5 +39,4 @@ function pickExample(value) {
|
|
|
39
39
|
function getExampleValue(example) {
|
|
40
40
|
return getRaw(example.dataValue ?? example.value);
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { getExampleValue, getPreferredType, getTagDisplayName, methodKeys, pickExample };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ServerObject } from "../types.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
//#region src/utils/use-server.d.ts
|
|
4
3
|
export interface SelectedServer {
|
|
5
4
|
url: string;
|
|
6
5
|
name?: string;
|
|
@@ -13,13 +12,12 @@ interface ServerContextType {
|
|
|
13
12
|
* The URL of `pathname` on the selected server, with the server variables resolved.
|
|
14
13
|
*
|
|
15
14
|
* Relative server URLs are resolved against the page origin, which also serves the request when
|
|
16
|
-
* no server is selected. On the server and during hydration the origin is
|
|
17
|
-
* `https://example.com` takes its place.
|
|
15
|
+
* no server is selected or its URL is invalid. On the server and during hydration the origin is
|
|
16
|
+
* unknown, so `https://example.com` takes its place.
|
|
18
17
|
*/
|
|
19
18
|
resolveUrl: (pathname?: string) => string;
|
|
20
19
|
setServer: (value: string) => void;
|
|
21
20
|
setServerVariables: (value: Record<string, string>) => void;
|
|
22
21
|
}
|
|
23
22
|
export declare function useServer(): ServerContextType;
|
|
24
|
-
//#endregion
|
|
25
23
|
export {};
|
package/dist/utils/use-server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useServerStore } from "../packages/shared-api/dist/utils/use-server-sto
|
|
|
3
3
|
import { joinURL, resolveServerUrl } from "../packages/shared-api/dist/utils/url.js";
|
|
4
4
|
import { createContext, use, useCallback, useMemo, useSyncExternalStore } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/utils/use-server.tsx
|
|
7
7
|
const ServerContext = createContext(null);
|
|
8
8
|
const keyOfServer = (server) => server.url;
|
|
9
9
|
const noop = () => () => {};
|
|
@@ -31,7 +31,8 @@ function ServerProvider({ servers, storageKeyPrefix, children }) {
|
|
|
31
31
|
const { server } = store;
|
|
32
32
|
const isClient = useSyncExternalStore(noop, () => true, () => false);
|
|
33
33
|
const resolveUrl = useCallback((pathname = "") => {
|
|
34
|
-
const
|
|
34
|
+
const origin = isClient ? window.location.origin : "https://example.com";
|
|
35
|
+
const base = (server && URL.parse(resolveServerUrl(server.url, server.variables), origin) || new URL(origin)).href;
|
|
35
36
|
return pathname ? joinURL(base, pathname) : base;
|
|
36
37
|
}, [server, isClient]);
|
|
37
38
|
return /* @__PURE__ */ jsx(ServerContext, {
|
|
@@ -53,5 +54,4 @@ function getDefaultValues(server) {
|
|
|
53
54
|
for (const [k, v] of Object.entries(server.variables)) if (v.default !== void 0) out[k] = String(v.default);
|
|
54
55
|
return out;
|
|
55
56
|
}
|
|
56
|
-
//#endregion
|
|
57
57
|
export { ServerProvider, useServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "12.5.
|
|
3
|
+
"version": "12.5.7",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@types/react-dom": "^19.3.0",
|
|
79
79
|
"fast-content-type-parse": "^4.0.1",
|
|
80
80
|
"fuma-cli": "^0.3.1",
|
|
81
|
-
"fumadocs-core": "16.17.
|
|
82
|
-
"fumadocs-ui": "npm:@fumadocs/base-ui@16.17.
|
|
81
|
+
"fumadocs-core": "16.17.9",
|
|
82
|
+
"fumadocs-ui": "npm:@fumadocs/base-ui@16.17.9",
|
|
83
83
|
"json-schema-typed": "^9.0.0",
|
|
84
84
|
"shared-api": "0.2.16",
|
|
85
85
|
"tsconfig": "0.0.0",
|