fumadocs-openapi 6.0.2 → 6.0.4
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/build-routes.d.ts +3 -3
- package/dist/generate-file.d.ts +1 -1
- package/dist/generate-file.js +2 -2
- package/dist/generate.d.ts +5 -5
- package/dist/generate.js +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/render/codeblock.d.ts +1 -1
- package/dist/render/heading.d.ts +1 -1
- package/dist/render/operation.d.ts +2 -2
- package/dist/render/operation.js +14 -14
- package/dist/render/playground.d.ts +2 -2
- package/dist/render/playground.js +3 -3
- package/dist/render/renderer.d.ts +2 -2
- package/dist/render/renderer.js +3 -3
- package/dist/render/schema.d.ts +2 -2
- package/dist/render/schema.js +3 -3
- package/dist/requests/curl.d.ts +1 -1
- package/dist/requests/curl.js +1 -1
- package/dist/requests/go.d.ts +1 -1
- package/dist/requests/go.js +1 -1
- package/dist/requests/javascript.d.ts +1 -1
- package/dist/requests/javascript.js +1 -1
- package/dist/requests/python.d.ts +1 -1
- package/dist/requests/python.js +1 -1
- package/dist/scalar/client.js +1 -1
- package/dist/scalar/index.d.ts +1 -1
- package/dist/scalar/index.js +1 -1
- package/dist/server/api-page.d.ts +3 -3
- package/dist/server/api-page.js +5 -5
- package/dist/server/create-method.d.ts +2 -2
- package/dist/server/create.d.ts +3 -3
- package/dist/server/create.js +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/source-api.js +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/ui/client.d.ts +10 -10
- package/dist/ui/client.js +3 -3
- package/dist/ui/contexts/api.d.ts +1 -1
- package/dist/ui/contexts/schema.d.ts +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +2 -2
- package/dist/ui/playground/fetcher.d.ts +2 -2
- package/dist/ui/playground/fetcher.js +1 -1
- package/dist/ui/playground/get-default-values.d.ts +1 -1
- package/dist/ui/playground/get-default-values.js +1 -1
- package/dist/ui/playground/index.d.ts +2 -2
- package/dist/ui/playground/index.d.ts.map +1 -1
- package/dist/ui/playground/index.js +12 -12
- package/dist/ui/playground/inputs.d.ts +1 -1
- package/dist/ui/playground/inputs.js +5 -5
- package/dist/ui/playground/resolve.d.ts +1 -1
- package/dist/ui/server-select.js +3 -3
- package/dist/utils/combine-schema.d.ts +1 -1
- package/dist/utils/generate-document.d.ts +4 -4
- package/dist/utils/generate-document.js +1 -1
- package/dist/utils/generate-sample.d.ts +2 -2
- package/dist/utils/generate-sample.d.ts.map +1 -1
- package/dist/utils/generate-sample.js +14 -5
- package/dist/utils/get-security.d.ts +2 -2
- package/dist/utils/get-typescript-schema.d.ts +2 -2
- package/dist/utils/process-document.d.ts +2 -2
- package/dist/utils/schema.d.ts +1 -1
- package/package.json +5 -5
package/dist/build-routes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Document } from './types';
|
|
2
|
-
import type { NoReference } from './utils/schema';
|
|
3
|
-
import type { OperationItem, WebhookItem } from './server/api-page';
|
|
1
|
+
import { type Document } from './types.js';
|
|
2
|
+
import type { NoReference } from './utils/schema.js';
|
|
3
|
+
import type { OperationItem, WebhookItem } from './server/api-page.js';
|
|
4
4
|
export declare const methodKeys: readonly ["get", "post", "patch", "delete", "head", "put"];
|
|
5
5
|
type Result = {
|
|
6
6
|
webhooks: (WebhookItem & {
|
package/dist/generate-file.d.ts
CHANGED
package/dist/generate-file.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join, parse } from 'node:path';
|
|
3
3
|
import fg from 'fast-glob';
|
|
4
|
-
import { generatePages, } from './generate';
|
|
5
|
-
import { generateAll, generateTags } from './generate';
|
|
4
|
+
import { generatePages, } from './generate.js';
|
|
5
|
+
import { generateAll, generateTags } from './generate.js';
|
|
6
6
|
export async function generateFiles(options) {
|
|
7
7
|
const { input, output, name: nameFn, per = 'operation', groupBy = 'none', cwd = process.cwd(), } = options;
|
|
8
8
|
const outputDir = join(cwd, output);
|
package/dist/generate.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type DocumentContext } from './utils/generate-document';
|
|
2
|
-
import type { OperationObject, PathItemObject } from './types';
|
|
3
|
-
import type { NoReference } from './utils/schema';
|
|
4
|
-
import type { OperationItem, WebhookItem } from './server/api-page';
|
|
5
|
-
import { type DocumentInput } from './utils/process-document';
|
|
1
|
+
import { type DocumentContext } from './utils/generate-document.js';
|
|
2
|
+
import type { OperationObject, PathItemObject } from './types.js';
|
|
3
|
+
import type { NoReference } from './utils/schema.js';
|
|
4
|
+
import type { OperationItem, WebhookItem } from './server/api-page.js';
|
|
5
|
+
import { type DocumentInput } from './utils/process-document.js';
|
|
6
6
|
export interface GenerateOptions {
|
|
7
7
|
/**
|
|
8
8
|
* Additional imports of your MDX components.
|
package/dist/generate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { getAPIPageItems } from './build-routes';
|
|
3
|
-
import { generateDocument, } from './utils/generate-document';
|
|
4
|
-
import { idToTitle } from './utils/id-to-title';
|
|
5
|
-
import { processDocument } from './utils/process-document';
|
|
2
|
+
import { getAPIPageItems } from './build-routes.js';
|
|
3
|
+
import { generateDocument, } from './utils/generate-document.js';
|
|
4
|
+
import { idToTitle } from './utils/id-to-title.js';
|
|
5
|
+
import { processDocument } from './utils/process-document.js';
|
|
6
6
|
async function dereference(pathOrDocument, options) {
|
|
7
7
|
return await processDocument(
|
|
8
8
|
// resolve paths
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './generate';
|
|
2
|
-
export * from './generate-file';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './generate.js';
|
|
2
|
+
export * from './generate-file.js';
|
|
3
|
+
export * from './types.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './generate';
|
|
2
|
-
export * from './generate-file';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './generate.js';
|
|
2
|
+
export * from './generate-file.js';
|
|
3
|
+
export * from './types.js';
|
package/dist/render/heading.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { RenderContext } from '../types';
|
|
2
|
+
import type { RenderContext } from '../types.js';
|
|
3
3
|
export declare function heading(depth: number, child: string, ctx: RenderContext): ReactNode;
|
|
4
4
|
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
|
-
import { type EndpointSample } from '../utils/generate-sample';
|
|
3
|
-
import type { MethodInformation, RenderContext } from '../types';
|
|
2
|
+
import { type EndpointSample } from '../utils/generate-sample.js';
|
|
3
|
+
import type { MethodInformation, RenderContext } from '../types.js';
|
|
4
4
|
export interface CodeSample {
|
|
5
5
|
lang: string;
|
|
6
6
|
label: string;
|
package/dist/render/operation.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
import { generateSample } from '../utils/generate-sample';
|
|
4
|
-
import * as CURL from '../requests/curl';
|
|
5
|
-
import * as JS from '../requests/javascript';
|
|
6
|
-
import * as Go from '../requests/go';
|
|
7
|
-
import * as Python from '../requests/python';
|
|
8
|
-
import { getPreferredType } from '../utils/schema';
|
|
9
|
-
import { getTypescriptSchema } from '../utils/get-typescript-schema';
|
|
10
|
-
import { getSecurities, getSecurityPrefix } from '../utils/get-security';
|
|
11
|
-
import { idToTitle } from '../utils/id-to-title';
|
|
12
|
-
import { Markdown } from './markdown';
|
|
13
|
-
import { heading } from './heading';
|
|
14
|
-
import { Schema } from './schema';
|
|
15
|
-
import { createMethod } from '../server/create-method';
|
|
16
|
-
import { methodKeys } from '../build-routes';
|
|
3
|
+
import { generateSample } from '../utils/generate-sample.js';
|
|
4
|
+
import * as CURL from '../requests/curl.js';
|
|
5
|
+
import * as JS from '../requests/javascript.js';
|
|
6
|
+
import * as Go from '../requests/go.js';
|
|
7
|
+
import * as Python from '../requests/python.js';
|
|
8
|
+
import { getPreferredType } from '../utils/schema.js';
|
|
9
|
+
import { getTypescriptSchema } from '../utils/get-typescript-schema.js';
|
|
10
|
+
import { getSecurities, getSecurityPrefix } from '../utils/get-security.js';
|
|
11
|
+
import { idToTitle } from '../utils/id-to-title.js';
|
|
12
|
+
import { Markdown } from './markdown.js';
|
|
13
|
+
import { heading } from './heading.js';
|
|
14
|
+
import { Schema } from './schema.js';
|
|
15
|
+
import { createMethod } from '../server/create-method.js';
|
|
16
|
+
import { methodKeys } from '../build-routes.js';
|
|
17
17
|
export function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2, }) {
|
|
18
18
|
const body = method.requestBody;
|
|
19
19
|
const security = method.security ?? ctx.schema.document.security;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { MethodInformation, RenderContext } from '../types';
|
|
3
|
-
import { type Security } from '../utils/get-security';
|
|
2
|
+
import type { MethodInformation, RenderContext } from '../types.js';
|
|
3
|
+
import { type Security } from '../utils/get-security.js';
|
|
4
4
|
interface BaseRequestField {
|
|
5
5
|
name: string;
|
|
6
6
|
description?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getPreferredType, } from '../utils/schema';
|
|
3
|
-
import { getSecurities } from '../utils/get-security';
|
|
4
|
-
import { APIPlayground } from '../ui';
|
|
2
|
+
import { getPreferredType, } from '../utils/schema.js';
|
|
3
|
+
import { getSecurities } from '../utils/get-security.js';
|
|
4
|
+
import { APIPlayground } from '../ui/index.js';
|
|
5
5
|
export function Playground({ path, method, ctx, }) {
|
|
6
6
|
let currentId = 0;
|
|
7
7
|
const bodyContent = method.requestBody?.content;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { MethodInformation, RenderContext, ServerObject } from '../types';
|
|
2
|
+
import type { MethodInformation, RenderContext, ServerObject } from '../types.js';
|
|
3
3
|
export interface ResponsesProps {
|
|
4
4
|
items: string[];
|
|
5
5
|
children: ReactNode;
|
|
@@ -71,6 +71,6 @@ export interface Renderer {
|
|
|
71
71
|
ctx: RenderContext;
|
|
72
72
|
}>;
|
|
73
73
|
}
|
|
74
|
-
export type { APIPlaygroundProps, RequestSchema, PrimitiveRequestField, ReferenceSchema, } from '../render/playground';
|
|
74
|
+
export type { APIPlaygroundProps, RequestSchema, PrimitiveRequestField, ReferenceSchema, } from '../render/playground.js';
|
|
75
75
|
export declare function createRenders(shikiOptions: RenderContext['shikiOptions']): Renderer;
|
|
76
76
|
//# sourceMappingURL=renderer.d.ts.map
|
package/dist/render/renderer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
3
3
|
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
|
|
4
|
-
import { CodeBlock } from '../render/codeblock';
|
|
5
|
-
import { API, Root, APIInfo, APIExample, Property, ObjectCollapsible, } from '../ui';
|
|
6
|
-
import { Playground } from '../render/playground';
|
|
4
|
+
import { CodeBlock } from '../render/codeblock.js';
|
|
5
|
+
import { API, Root, APIInfo, APIExample, Property, ObjectCollapsible, } from '../ui/index.js';
|
|
6
|
+
import { Playground } from '../render/playground.js';
|
|
7
7
|
export function createRenders(shikiOptions) {
|
|
8
8
|
return {
|
|
9
9
|
Root: (props) => (_jsx(Root, { shikiOptions: shikiOptions, ...props, children: props.children })),
|
package/dist/render/schema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { NoReference, type ParsedSchema } from '../utils/schema';
|
|
3
|
-
import type { RenderContext } from '../types';
|
|
2
|
+
import { NoReference, type ParsedSchema } from '../utils/schema.js';
|
|
3
|
+
import type { RenderContext } from '../types.js';
|
|
4
4
|
interface Context {
|
|
5
5
|
readOnly: boolean;
|
|
6
6
|
writeOnly: boolean;
|
package/dist/render/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isNullable } from '../utils/schema';
|
|
3
|
-
import { combineSchema } from '../utils/combine-schema';
|
|
4
|
-
import { Markdown } from './markdown';
|
|
2
|
+
import { isNullable } from '../utils/schema.js';
|
|
3
|
+
import { combineSchema } from '../utils/combine-schema.js';
|
|
4
|
+
import { Markdown } from './markdown.js';
|
|
5
5
|
const keys = {
|
|
6
6
|
default: 'Default',
|
|
7
7
|
minimum: 'Minimum',
|
package/dist/requests/curl.d.ts
CHANGED
package/dist/requests/curl.js
CHANGED
package/dist/requests/go.d.ts
CHANGED
package/dist/requests/go.js
CHANGED
package/dist/requests/python.js
CHANGED
package/dist/scalar/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { cn } from 'fumadocs-ui/components/api';
|
|
4
4
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
5
5
|
import { ApiClientModalProvider, useApiClientModal, } from '@scalar/api-client-react';
|
|
6
|
-
import { MethodLabel } from '../ui/components/method-label';
|
|
6
|
+
import { MethodLabel } from '../ui/components/method-label.js';
|
|
7
7
|
import { useTheme } from 'next-themes';
|
|
8
8
|
import { useEffect, useState } from 'react';
|
|
9
9
|
export default function ScalarPlayground({ path, method, spec, }) {
|
package/dist/scalar/index.d.ts
CHANGED
package/dist/scalar/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import dynamic from 'next/dynamic';
|
|
3
|
-
const Client = dynamic(() => import('./client'));
|
|
3
|
+
const Client = dynamic(() => import('./client.js'));
|
|
4
4
|
export function APIPlayground({ path, method, ctx, }) {
|
|
5
5
|
return (_jsx(Client, { method: method.method, path: path, spec: ctx.schema.downloaded }));
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RenderContext } from '../types';
|
|
2
|
-
import { type Renderer } from '../render/renderer';
|
|
1
|
+
import type { RenderContext } from '../types.js';
|
|
2
|
+
import { type Renderer } from '../render/renderer.js';
|
|
3
3
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
4
|
-
import { type DocumentInput, type ProcessedDocument } from '../utils/process-document';
|
|
4
|
+
import { type DocumentInput, type ProcessedDocument } from '../utils/process-document.js';
|
|
5
5
|
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema'>;
|
|
6
6
|
export interface ApiPageProps extends ApiPageContextProps {
|
|
7
7
|
document: DocumentInput;
|
package/dist/server/api-page.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Slugger from 'github-slugger';
|
|
3
|
-
import { Operation } from '../render/operation';
|
|
4
|
-
import { createMethod } from '../server/create-method';
|
|
5
|
-
import { createRenders } from '../render/renderer';
|
|
6
|
-
import { processDocument, } from '../utils/process-document';
|
|
7
|
-
import { getUrl } from '../utils/server-url';
|
|
3
|
+
import { Operation } from '../render/operation.js';
|
|
4
|
+
import { createMethod } from '../server/create-method.js';
|
|
5
|
+
import { createRenders } from '../render/renderer.js';
|
|
6
|
+
import { processDocument, } from '../utils/process-document.js';
|
|
7
|
+
import { getUrl } from '../utils/server-url.js';
|
|
8
8
|
export async function APIPage(props) {
|
|
9
9
|
const { operations, hasHead = true, webhooks, disableCache = process.env.NODE_ENV === 'development', } = props;
|
|
10
10
|
const processed = await processDocument(props.document, disableCache);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MethodInformation, OperationObject, PathItemObject } from '../types';
|
|
2
|
-
import type { NoReference } from '../utils/schema';
|
|
1
|
+
import type { MethodInformation, OperationObject, PathItemObject } from '../types.js';
|
|
2
|
+
import type { NoReference } from '../utils/schema.js';
|
|
3
3
|
/**
|
|
4
4
|
* Summarize method endpoint information
|
|
5
5
|
*/
|
package/dist/server/create.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
-
import { type ApiPageProps } from '../server/api-page';
|
|
3
|
-
import type { DocumentInput } from '../utils/process-document';
|
|
4
|
-
import { createProxy } from '../server/proxy';
|
|
2
|
+
import { type ApiPageProps } from '../server/api-page.js';
|
|
3
|
+
import type { DocumentInput } from '../utils/process-document.js';
|
|
4
|
+
import { createProxy } from '../server/proxy.js';
|
|
5
5
|
export interface OpenAPIOptions extends Omit<Partial<ApiPageProps>, 'document'> {
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Pass document to `APIPage` instead
|
package/dist/server/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { APIPage } from '../server/api-page';
|
|
3
|
-
import { createProxy } from '../server/proxy';
|
|
2
|
+
import { APIPage } from '../server/api-page.js';
|
|
3
|
+
import { createProxy } from '../server/proxy.js';
|
|
4
4
|
export function createOpenAPI(options = {}) {
|
|
5
5
|
return {
|
|
6
6
|
createProxy,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './create';
|
|
2
|
-
export * from './source-api';
|
|
1
|
+
export * from './create.js';
|
|
2
|
+
export * from './source-api.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './create';
|
|
2
|
-
export * from './source-api';
|
|
1
|
+
export * from './create.js';
|
|
2
|
+
export * from './source-api.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
-
import { getBadgeColor } from '../ui/components/variants';
|
|
3
|
+
import { getBadgeColor } from '../ui/components/variants.js';
|
|
4
4
|
/**
|
|
5
5
|
* Source API Integration
|
|
6
6
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 as V3_1 } from 'openapi-types';
|
|
2
2
|
import type { default as Slugger } from 'github-slugger';
|
|
3
|
-
import { type Renderer } from './render/renderer';
|
|
4
|
-
import type { EndpointSample } from './utils/generate-sample';
|
|
5
|
-
import type { CodeSample } from './render/operation';
|
|
3
|
+
import { type Renderer } from './render/renderer.js';
|
|
4
|
+
import type { EndpointSample } from './utils/generate-sample.js';
|
|
5
|
+
import type { CodeSample } from './render/operation.js';
|
|
6
6
|
import type { BuiltinTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from 'shiki';
|
|
7
|
-
import type { NoReference } from './utils/schema';
|
|
8
|
-
import type { ProcessedDocument } from './utils/process-document';
|
|
7
|
+
import type { NoReference } from './utils/schema.js';
|
|
8
|
+
import type { ProcessedDocument } from './utils/process-document.js';
|
|
9
9
|
export type Document = V3_1.Document;
|
|
10
10
|
export type OperationObject = V3_1.OperationObject;
|
|
11
11
|
export type ParameterObject = V3_1.ParameterObject;
|
package/dist/ui/client.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type RootProps } from '../render/renderer';
|
|
3
|
-
import type { RenderContext } from '../types';
|
|
4
|
-
export declare const APIPlayground: import("react").ComponentType<import("../render/renderer").APIPlaygroundProps & {
|
|
2
|
+
import { type RootProps } from '../render/renderer.js';
|
|
3
|
+
import type { RenderContext } from '../types.js';
|
|
4
|
+
export declare const APIPlayground: import("react").ComponentType<import("../render/renderer.js").APIPlaygroundProps & {
|
|
5
5
|
fields?: {
|
|
6
|
-
auth?: import("./playground").CustomField<"authorization", import("../render/renderer").RequestSchema>;
|
|
7
|
-
path?: import("./playground").CustomField<`path.${string}`, import("../render/renderer").PrimitiveRequestField>;
|
|
8
|
-
query?: import("./playground").CustomField<`query.${string}`, import("../render/renderer").PrimitiveRequestField>;
|
|
9
|
-
header?: import("./playground").CustomField<`header.${string}`, import("../render/renderer").PrimitiveRequestField>;
|
|
10
|
-
body?: import("./playground").CustomField<"body", import("../render/renderer").RequestSchema>;
|
|
6
|
+
auth?: import("./playground/index.js").CustomField<"authorization", import("../render/renderer.js").RequestSchema>;
|
|
7
|
+
path?: import("./playground/index.js").CustomField<`path.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
|
|
8
|
+
query?: import("./playground/index.js").CustomField<`query.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
|
|
9
|
+
header?: import("./playground/index.js").CustomField<`header.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
|
|
10
|
+
body?: import("./playground/index.js").CustomField<"body", import("../render/renderer.js").RequestSchema>;
|
|
11
11
|
};
|
|
12
12
|
components?: Partial<{
|
|
13
13
|
ResultDisplay: import("react").FC<{
|
|
14
|
-
data: import("./playground/fetcher").FetchResult;
|
|
14
|
+
data: import("./playground/fetcher.js").FetchResult;
|
|
15
15
|
}>;
|
|
16
16
|
}>;
|
|
17
17
|
} & HTMLAttributes<HTMLFormElement>>;
|
|
18
18
|
export declare function Root({ children, baseUrl, className, shikiOptions, servers, ...props }: RootProps & {
|
|
19
19
|
shikiOptions: RenderContext['shikiOptions'];
|
|
20
20
|
} & HTMLAttributes<HTMLDivElement>): ReactNode;
|
|
21
|
-
export { useSchemaContext } from './contexts/schema';
|
|
21
|
+
export { useSchemaContext } from './contexts/schema.js';
|
|
22
22
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/ui/client.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from 'fumadocs-ui/components/api';
|
|
4
4
|
import dynamic from 'next/dynamic';
|
|
5
|
-
import { ApiProvider } from '../ui/contexts/api';
|
|
6
|
-
export const APIPlayground = dynamic(() => import('./playground').then((mod) => mod.APIPlayground));
|
|
5
|
+
import { ApiProvider } from '../ui/contexts/api.js';
|
|
6
|
+
export const APIPlayground = dynamic(() => import('./playground/index.js').then((mod) => mod.APIPlayground));
|
|
7
7
|
export function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
|
|
8
8
|
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { servers: servers, shikiOptions: shikiOptions, defaultBaseUrl: baseUrl, children: children }) }));
|
|
9
9
|
}
|
|
10
|
-
export { useSchemaContext } from './contexts/schema';
|
|
10
|
+
export { useSchemaContext } from './contexts/schema.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
|
-
import { type ReferenceSchema, type RequestSchema } from '../../render/playground';
|
|
2
|
+
import { type ReferenceSchema, type RequestSchema } from '../../render/playground.js';
|
|
3
3
|
interface SchemaContextType {
|
|
4
4
|
references: Record<string, RequestSchema>;
|
|
5
5
|
dynamic: RefObject<Map<string, DynamicField>>;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type { PropertyProps } from '../render/renderer';
|
|
3
|
-
export { Root, useSchemaContext, APIPlayground } from './client';
|
|
2
|
+
import type { PropertyProps } from '../render/renderer.js';
|
|
3
|
+
export { Root, useSchemaContext, APIPlayground } from './client.js';
|
|
4
4
|
export declare function APIInfo({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare function API({ children, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function Property({ name, type, required, deprecated, children, }: PropertyProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/ui/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { buttonVariants, cn } from 'fumadocs-ui/components/api';
|
|
3
|
-
import { badgeVariants } from '../ui/components/variants';
|
|
3
|
+
import { badgeVariants } from '../ui/components/variants.js';
|
|
4
4
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
|
|
5
5
|
import { ChevronDown } from 'lucide-react';
|
|
6
|
-
export { Root, useSchemaContext, APIPlayground } from './client';
|
|
6
|
+
export { Root, useSchemaContext, APIPlayground } from './client.js';
|
|
7
7
|
export function APIInfo({ className, ...props }) {
|
|
8
8
|
return (_jsx("div", { className: cn('min-w-0 flex-1', className), ...props, children: props.children }));
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type RequestSchema } from '../../render/playground';
|
|
2
|
-
import { type DynamicField } from '../../ui/contexts/schema';
|
|
1
|
+
import { type RequestSchema } from '../../render/playground.js';
|
|
2
|
+
import { type DynamicField } from '../../ui/contexts/schema.js';
|
|
3
3
|
export interface FetchOptions {
|
|
4
4
|
url: string;
|
|
5
5
|
method: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PrimitiveRequestField, RequestSchema } from '../../render/playground';
|
|
1
|
+
import type { PrimitiveRequestField, RequestSchema } from '../../render/playground.js';
|
|
2
2
|
export declare function getDefaultValue(item: RequestSchema, references: Record<string, RequestSchema>): unknown;
|
|
3
3
|
export declare function getDefaultValues(field: PrimitiveRequestField[], context: Record<string, RequestSchema>): Record<string, unknown>;
|
|
4
4
|
//# sourceMappingURL=get-default-values.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolve } from '../../ui/playground/resolve';
|
|
1
|
+
import { resolve } from '../../ui/playground/resolve.js';
|
|
2
2
|
export function getDefaultValue(item, references) {
|
|
3
3
|
if (item.type === 'object')
|
|
4
4
|
return Object.fromEntries(Object.entries(item.properties).map(([key, prop]) => [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactElement, type HTMLAttributes, type FC, type ReactNode } from 'react';
|
|
2
2
|
import type { FieldPath, UseFormStateReturn, ControllerFieldState, ControllerRenderProps } from 'react-hook-form';
|
|
3
|
-
import type { FetchResult } from '../../ui/playground/fetcher';
|
|
4
|
-
import type { APIPlaygroundProps, PrimitiveRequestField, RequestSchema } from '../../render/playground';
|
|
3
|
+
import type { FetchResult } from '../../ui/playground/fetcher.js';
|
|
4
|
+
import type { APIPlaygroundProps, PrimitiveRequestField, RequestSchema } from '../../render/playground.js';
|
|
5
5
|
interface FormValues {
|
|
6
6
|
authorization: string | {
|
|
7
7
|
username: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAInB,KAAK,EAAE,EAEP,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,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controller, FormProvider, useForm } from 'react-hook-form';
|
|
5
5
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
6
|
-
import { useApiContext } from '../../ui/contexts/api';
|
|
7
|
-
import { getDefaultValue, getDefaultValues, } from '../../ui/playground/get-default-values';
|
|
8
|
-
import { FieldSet, ObjectInput } from '../../ui/playground/inputs';
|
|
9
|
-
import { SchemaContext } from '../contexts/schema';
|
|
10
|
-
import { getStatusInfo } from '../../ui/playground/status-info';
|
|
11
|
-
import { getUrl } from '../../utils/server-url';
|
|
6
|
+
import { useApiContext } from '../../ui/contexts/api.js';
|
|
7
|
+
import { getDefaultValue, getDefaultValues, } from '../../ui/playground/get-default-values.js';
|
|
8
|
+
import { FieldSet, ObjectInput } from '../../ui/playground/inputs.js';
|
|
9
|
+
import { SchemaContext } from '../contexts/schema.js';
|
|
10
|
+
import { getStatusInfo } from '../../ui/playground/status-info.js';
|
|
11
|
+
import { getUrl } from '../../utils/server-url.js';
|
|
12
12
|
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
13
|
-
import { MethodLabel } from '../../ui/components/method-label';
|
|
14
|
-
import { useQuery } from '../../utils/use-query';
|
|
15
|
-
import ServerSelect from '../../ui/server-select';
|
|
13
|
+
import { MethodLabel } from '../../ui/components/method-label.js';
|
|
14
|
+
import { useQuery } from '../../utils/use-query.js';
|
|
15
|
+
import ServerSelect from '../../ui/server-select.js';
|
|
16
16
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
|
|
17
17
|
import { ChevronDown } from 'lucide-react';
|
|
18
18
|
function defaultAuthValue(auth) {
|
|
@@ -27,7 +27,7 @@ function defaultAuthValue(auth) {
|
|
|
27
27
|
return 'Bearer';
|
|
28
28
|
}
|
|
29
29
|
export function APIPlayground({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
|
|
30
|
-
const { serverRef } = useApiContext();
|
|
30
|
+
const { serverRef, servers } = useApiContext();
|
|
31
31
|
const dynamicRef = useRef(new Map());
|
|
32
32
|
const form = useForm({
|
|
33
33
|
defaultValues: {
|
|
@@ -39,7 +39,7 @@ export function APIPlayground({ route, method = 'GET', authorization, path = [],
|
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
const testQuery = useQuery(async (input) => {
|
|
42
|
-
const fetcher = await import('./fetcher').then((mod) => mod.createBrowserFetcher(body, schemas));
|
|
42
|
+
const fetcher = await import('./fetcher.js').then((mod) => mod.createBrowserFetcher(body, schemas));
|
|
43
43
|
const query = { ...input.query };
|
|
44
44
|
const header = { ...input.header };
|
|
45
45
|
if (input.authorization && authorization) {
|
|
@@ -120,7 +120,7 @@ export function APIPlayground({ route, method = 'GET', authorization, path = [],
|
|
|
120
120
|
}
|
|
121
121
|
return (_jsx(FieldSet, { name: info.name, fieldName: fieldName, field: info }, key));
|
|
122
122
|
}
|
|
123
|
-
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: schemas, dynamic: dynamicRef }), [schemas]), children: _jsxs("form", { ...props, className: cn('not-prose flex flex-col gap-2 rounded-xl border p-3 shadow-md', props.className), onSubmit: onSubmit, children: [_jsx(FormHeader, { method: method, route: route, isLoading: testQuery.isLoading }), _jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, {}) }), header.length > 0 || authorization ? (_jsxs(CollapsiblePanel, { title: "Headers", children: [authorization?.type === 'http' &&
|
|
123
|
+
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: schemas, dynamic: dynamicRef }), [schemas]), children: _jsxs("form", { ...props, className: cn('not-prose flex flex-col gap-2 rounded-xl border p-3 shadow-md', props.className), onSubmit: onSubmit, children: [_jsx(FormHeader, { method: method, route: route, isLoading: testQuery.isLoading }), servers.length > 1 ? (_jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, {}) })) : null, header.length > 0 || authorization ? (_jsxs(CollapsiblePanel, { title: "Headers", children: [authorization?.type === 'http' &&
|
|
124
124
|
authorization.scheme === 'basic'
|
|
125
125
|
? renderCustomField('authorization', {
|
|
126
126
|
name: 'Authorization',
|
|
@@ -3,11 +3,11 @@ import { useState, } from 'react';
|
|
|
3
3
|
import { Plus, Trash2 } from 'lucide-react';
|
|
4
4
|
import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
|
|
5
5
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
6
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select';
|
|
7
|
-
import { resolve } from '../../ui/playground/resolve';
|
|
8
|
-
import { Input, labelVariants } from '../../ui/components/input';
|
|
9
|
-
import { getDefaultValue } from '../../ui/playground/get-default-values';
|
|
10
|
-
import { useSchemaContext } from '../../ui/contexts/schema';
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
|
|
7
|
+
import { resolve } from '../../ui/playground/resolve.js';
|
|
8
|
+
import { Input, labelVariants } from '../../ui/components/input.js';
|
|
9
|
+
import { getDefaultValue } from '../../ui/playground/get-default-values.js';
|
|
10
|
+
import { useSchemaContext } from '../../ui/contexts/schema.js';
|
|
11
11
|
function FieldHeader({ name, required = false, type, ...props }) {
|
|
12
12
|
return (_jsxs("label", { ...props, className: cn('w-full inline-flex items-center gap-1', props.className), children: [_jsx("span", { className: cn(labelVariants()), children: name }), required ? _jsx("span", { className: "text-red-500", children: "*" }) : null, _jsx("div", { className: "flex-1" }), type ? (_jsx("code", { className: "text-xs text-fd-muted-foreground", children: type })) : null, props.children] }));
|
|
13
13
|
}
|
package/dist/ui/server-select.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useApiContext, useServerSelectContext } from '../ui/contexts/api';
|
|
4
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select';
|
|
5
|
-
import { Input, labelVariants } from '../ui/components/input';
|
|
3
|
+
import { useApiContext, useServerSelectContext } from '../ui/contexts/api.js';
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
|
|
5
|
+
import { Input, labelVariants } from '../ui/components/input.js';
|
|
6
6
|
import { cn } from 'fumadocs-ui/components/api';
|
|
7
7
|
export default function ServerSelect(props) {
|
|
8
8
|
const { servers } = useApiContext();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiPageProps } from '../server/api-page';
|
|
2
|
-
import type { GenerateOptions } from '../generate';
|
|
3
|
-
import type { Document, TagObject } from '../types';
|
|
4
|
-
import type { NoReference } from '../utils/schema';
|
|
1
|
+
import type { ApiPageProps } from '../server/api-page.js';
|
|
2
|
+
import type { GenerateOptions } from '../generate.js';
|
|
3
|
+
import type { Document, TagObject } from '../types.js';
|
|
4
|
+
import type { NoReference } from '../utils/schema.js';
|
|
5
5
|
export type DocumentContext = {
|
|
6
6
|
type: 'tag';
|
|
7
7
|
tag: TagObject | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dump } from 'js-yaml';
|
|
2
2
|
import Slugger from 'github-slugger';
|
|
3
|
-
import { idToTitle } from '../utils/id-to-title';
|
|
3
|
+
import { idToTitle } from '../utils/id-to-title.js';
|
|
4
4
|
export function generateDocument(options) {
|
|
5
5
|
const { frontmatter, includeDescription = false } = options;
|
|
6
6
|
const out = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MethodInformation, RenderContext } from '../types';
|
|
2
|
-
import { type ParsedSchema } from '../utils/schema';
|
|
1
|
+
import type { MethodInformation, RenderContext } from '../types.js';
|
|
2
|
+
import { type ParsedSchema } from '../utils/schema.js';
|
|
3
3
|
/**
|
|
4
4
|
* Sample info of endpoint
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-sample.d.ts","sourceRoot":"","sources":["../../src/utils/generate-sample.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,YAAY,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,GAC/C,cAAc,
|
|
1
|
+
{"version":3,"file":"generate-sample.d.ts","sourceRoot":"","sources":["../../src/utils/generate-sample.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,YAAY,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,GAC/C,cAAc,CAoHhB"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { sample } from 'openapi-sampler';
|
|
2
|
-
import { getPreferredType, } from '../utils/schema';
|
|
3
|
-
import { getSecurities, getSecurityPrefix } from '../utils/get-security';
|
|
2
|
+
import { getPreferredType, } from '../utils/schema.js';
|
|
3
|
+
import { getSecurities, getSecurityPrefix } from '../utils/get-security.js';
|
|
4
4
|
export function generateSample(path, method, { baseUrl, schema: { document } }) {
|
|
5
5
|
const params = [];
|
|
6
6
|
const responses = {};
|
|
7
7
|
for (const param of method.parameters ?? []) {
|
|
8
8
|
if (param.schema) {
|
|
9
|
+
let value = param.example ?? sample(param.schema);
|
|
10
|
+
if (param.schema.type && param.schema.type === value) {
|
|
11
|
+
// if no example is defined make sure its visible that there is still a placeholder, equal to auth <token>
|
|
12
|
+
value = `<${value}>`;
|
|
13
|
+
}
|
|
9
14
|
params.push({
|
|
10
15
|
name: param.name,
|
|
11
16
|
in: param.in,
|
|
12
17
|
schema: param.schema,
|
|
13
|
-
sample:
|
|
18
|
+
sample: value,
|
|
14
19
|
});
|
|
15
20
|
}
|
|
16
21
|
else if (param.content) {
|
|
@@ -73,7 +78,11 @@ export function generateSample(path, method, { baseUrl, schema: { document } })
|
|
|
73
78
|
let pathWithParameters = path;
|
|
74
79
|
const queryParams = new URLSearchParams();
|
|
75
80
|
for (const param of params) {
|
|
76
|
-
|
|
81
|
+
let value = generateBody(method.method, param.schema);
|
|
82
|
+
if (param.schema.type && param.schema.type === value) {
|
|
83
|
+
// if no example is defined make sure its visible that there is still a placeholder, equal to auth <token>
|
|
84
|
+
value = `<${value}>`;
|
|
85
|
+
}
|
|
77
86
|
if (param.in === 'query')
|
|
78
87
|
queryParams.append(param.name, String(value));
|
|
79
88
|
if (param.in === 'path')
|
|
@@ -82,7 +91,7 @@ export function generateSample(path, method, { baseUrl, schema: { document } })
|
|
|
82
91
|
if (queryParams.size > 0)
|
|
83
92
|
pathWithParameters = `${pathWithParameters}?${queryParams.toString()}`;
|
|
84
93
|
return {
|
|
85
|
-
url:
|
|
94
|
+
url: `${baseUrl}${pathWithParameters}`,
|
|
86
95
|
body: bodyOutput,
|
|
87
96
|
responses,
|
|
88
97
|
method: method.method,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Document, SecurityRequirementObject, SecuritySchemeObject } from '../types';
|
|
2
|
-
import { type NoReference } from '../utils/schema';
|
|
1
|
+
import type { Document, SecurityRequirementObject, SecuritySchemeObject } from '../types.js';
|
|
2
|
+
import { type NoReference } from '../utils/schema.js';
|
|
3
3
|
export type Security = SecuritySchemeObject & {
|
|
4
4
|
scopes: string[];
|
|
5
5
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EndpointSample } from '../utils/generate-sample';
|
|
2
|
-
import { DereferenceMap } from '../types';
|
|
1
|
+
import type { EndpointSample } from '../utils/generate-sample.js';
|
|
2
|
+
import { DereferenceMap } from '../types.js';
|
|
3
3
|
export declare function getTypescriptSchema(endpoint: EndpointSample, code: string, dereferenceMap: DereferenceMap): Promise<string | undefined>;
|
|
4
4
|
//# sourceMappingURL=get-typescript-schema.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DereferenceMap, Document } from '../types';
|
|
2
|
-
import type { NoReference } from '../utils/schema';
|
|
1
|
+
import type { DereferenceMap, Document } from '../types.js';
|
|
2
|
+
import type { NoReference } from '../utils/schema.js';
|
|
3
3
|
import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
4
4
|
export type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
5
5
|
export type ProcessedDocument = {
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReferenceObject } from '../types';
|
|
1
|
+
import type { ReferenceObject } from '../types.js';
|
|
2
2
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
3
3
|
export type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? {
|
|
4
4
|
[K in keyof T]: NoReference<T[K]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"fast-glob": "^3.3.3",
|
|
45
45
|
"github-slugger": "^2.0.0",
|
|
46
46
|
"hast-util-to-jsx-runtime": "^2.3.2",
|
|
47
|
-
"lucide-react": "^0.474.0",
|
|
48
47
|
"js-yaml": "^4.1.0",
|
|
48
|
+
"lucide-react": "^0.474.0",
|
|
49
49
|
"next-themes": "^0.4.4",
|
|
50
50
|
"openapi-sampler": "^1.6.1",
|
|
51
51
|
"react-hook-form": "^7.54.2",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"remark-rehype": "^11.1.1",
|
|
54
54
|
"shiki": "^2.2.0",
|
|
55
55
|
"xml-js": "^1.6.11",
|
|
56
|
-
"fumadocs-core": "15.0.
|
|
57
|
-
"fumadocs-ui": "15.0.
|
|
56
|
+
"fumadocs-core": "15.0.3",
|
|
57
|
+
"fumadocs-ui": "15.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@scalar/api-client-react": "^1.1.22",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@types/react": "^19.0.8",
|
|
65
65
|
"next": "15.1.6",
|
|
66
66
|
"openapi-types": "^12.1.3",
|
|
67
|
-
"tailwindcss": "^4.0.
|
|
67
|
+
"tailwindcss": "^4.0.3",
|
|
68
68
|
"tsc-alias": "^1.8.10",
|
|
69
69
|
"eslint-config-custom": "0.0.0",
|
|
70
70
|
"tsconfig": "0.0.0"
|