fumadocs-openapi 11.4.2 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/css/preset.css +0 -1
- package/dist/_virtual/_rolldown/runtime.js +10 -1
- package/dist/generate-file.d.ts +2 -2
- package/dist/generate-file.js +1 -1
- package/dist/i18n.d.ts +6 -8
- package/dist/i18n.js +2 -17
- package/dist/index.browser.d.ts +13 -0
- package/dist/index.browser.js +11 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/operation.d.ts +133 -0
- package/dist/operation.js +296 -0
- package/dist/packages/shared-api/dist/.translations/index.d.ts +29 -0
- package/dist/packages/shared-api/dist/.translations/keys.js +28 -0
- package/dist/packages/shared-api/dist/auto-anchor/client.js +20 -0
- package/dist/packages/shared-api/dist/auto-anchor/index.js +17 -0
- package/dist/packages/shared-api/dist/codegen.d.ts +42 -0
- package/dist/packages/shared-api/dist/codegen.js +35 -0
- package/dist/packages/shared-api/dist/components/accordion.js +71 -0
- package/dist/packages/shared-api/dist/components/badge.js +21 -0
- package/dist/packages/shared-api/dist/components/collapsible.d.ts +7 -0
- package/dist/packages/shared-api/dist/components/collapsible.js +16 -0
- package/dist/packages/shared-api/dist/components/defaults.d.ts +20 -0
- package/dist/packages/shared-api/dist/components/defaults.js +70 -0
- package/dist/packages/shared-api/dist/components/dialog.js +55 -0
- package/dist/packages/shared-api/dist/components/input.js +14 -0
- package/dist/packages/shared-api/dist/components/label.js +11 -0
- package/dist/packages/shared-api/dist/components/playground/inputs.js +439 -0
- package/dist/packages/shared-api/dist/components/playground/schema.js +112 -0
- package/dist/packages/shared-api/dist/components/popover.js +23 -0
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +12 -0
- package/dist/packages/shared-api/dist/components/schema/client.js +508 -0
- package/dist/packages/shared-api/dist/components/schema/index.d.ts +9 -0
- package/dist/packages/shared-api/dist/components/schema/index.js +28 -0
- package/dist/packages/shared-api/dist/components/select-tab.js +54 -0
- package/dist/packages/shared-api/dist/components/select.js +70 -0
- package/dist/packages/shared-api/dist/components/spinner.js +14 -0
- package/dist/packages/shared-api/dist/i18n.d.ts +3 -0
- package/dist/packages/shared-api/dist/i18n.js +7 -0
- package/dist/packages/shared-api/dist/utils/cn.js +2 -0
- package/dist/packages/shared-api/dist/utils/id-to-title.js +12 -0
- package/dist/packages/shared-api/dist/utils/is-plain-object.js +8 -0
- package/dist/packages/shared-api/dist/utils/merge-refs.js +11 -0
- package/dist/packages/shared-api/dist/utils/url.js +13 -0
- package/dist/{utils → packages/shared-api/dist/utils}/use-query.js +2 -1
- package/dist/packages/shared-api/dist/utils/use-server-store.js +56 -0
- package/dist/playground/auth.d.ts +37 -0
- package/dist/playground/auth.js +216 -21
- package/dist/playground/fetcher.d.ts +11 -1
- package/dist/playground/index.d.ts +3 -0
- package/dist/playground/index.js +3 -0
- package/dist/requests/generators/csharp.js +0 -1
- package/dist/requests/generators/go.js +0 -1
- package/dist/requests/generators/index.d.ts +4 -4
- package/dist/requests/generators/index.js +2 -2
- package/dist/requests/generators/java.js +0 -1
- package/dist/requests/generators/javascript.js +0 -1
- package/dist/requests/generators/python.js +0 -1
- package/dist/requests/generators/rust.js +0 -1
- package/dist/requests/index.d.ts +4 -0
- package/dist/requests/index.js +3 -0
- package/dist/requests/media/adapter.d.ts +1 -0
- package/dist/requests/media/encode.d.ts +7 -2
- package/dist/requests/media/resolve-adapter.d.ts +20 -0
- package/dist/server/index.d.ts +4 -7
- package/dist/server/index.js +1 -7
- package/dist/types.d.ts +0 -14
- package/dist/ui/base.d.ts +3 -2
- package/dist/ui/base.js +15 -166
- package/dist/ui/components/codeblock.js +3 -10
- package/dist/ui/components/heading.js +10 -19
- package/dist/ui/components/markdown.js +4 -6
- package/dist/ui/components/method-label.js +2 -17
- package/dist/ui/components/schema.js +28 -0
- package/dist/ui/index.d.ts +7 -198
- package/dist/ui/index.js +1 -3
- package/dist/ui/operation/index.js +143 -231
- package/dist/ui/operation/request-tabs.js +15 -23
- package/dist/ui/operation/response-tabs.js +9 -53
- package/dist/ui/operation/usage-tabs.js +35 -93
- package/dist/{playground → ui/playground}/client.d.ts +10 -21
- package/dist/ui/playground/client.js +432 -0
- package/dist/{playground → ui/playground}/components/oauth-dialog.js +27 -92
- package/dist/{playground → ui/playground}/components/result-display.d.ts +2 -2
- package/dist/{playground → ui/playground}/components/result-display.js +7 -7
- package/dist/{playground → ui/playground}/components/server-select.js +12 -13
- package/dist/{playground → ui/playground}/status-info.js +2 -2
- package/dist/{scalar → ui/scalar}/client.js +8 -6
- package/dist/{scalar → ui/scalar}/index.d.ts +2 -2
- package/dist/{scalar → ui/scalar}/index.js +3 -7
- package/dist/utils/create-page.d.ts +216 -0
- package/dist/utils/create-page.js +221 -0
- package/dist/utils/document/dereference.d.ts +2 -2
- package/dist/utils/document/dereference.js +8 -3
- package/dist/utils/document/load.js +2 -2
- package/dist/utils/get-example-requests.js +11 -13
- package/dist/utils/pages/builder.d.ts +15 -2
- package/dist/utils/pages/builder.js +6 -6
- package/dist/utils/pages/preset-auto.d.ts +1 -1
- package/dist/utils/pages/preset-auto.js +3 -3
- package/dist/utils/pages/to-static-data.js +4 -4
- package/dist/utils/pages/to-text.d.ts +1 -1
- package/dist/utils/pages/to-text.js +3 -5
- package/dist/utils/schema.js +5 -5
- package/dist/utils/use-server.d.ts +24 -0
- package/dist/utils/use-server.js +57 -0
- package/package.json +31 -20
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +0 -508
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +0 -152
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +0 -61
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +0 -25
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +0 -15
- package/dist/playground/client.js +0 -574
- package/dist/ui/contexts/api.d.ts +0 -17
- package/dist/ui/contexts/api.js +0 -84
- package/dist/ui/create-client.d.ts +0 -9
- package/dist/ui/create-client.js +0 -7
- package/dist/ui/operation/context.d.ts +0 -15
- package/dist/ui/operation/context.js +0 -48
- package/dist/ui/operation/request-tabs.d.ts +0 -12
- package/dist/ui/operation/response-tabs.d.ts +0 -30
- package/dist/utils/get-example-requests.d.ts +0 -11
- package/dist/utils/schema.d.ts +0 -3
- package/dist/utils/storage-key.js +0 -15
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("--- --fd-docs-row-1 -mode -ms-2 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @defaultValue @deprecated @fuma-translate/react @fumari/json-schema-ts @fumari/stf @param @private @scalar/api-client-react @see @typescript-eslint/no-explicit-any a access access_token active adapter adapters addListener against all allFlows allow already alt an anchorSegments and animate-spin apiExample apiKey apiPlayground application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml apply are array as assume async at auth-specific authCodeQuery authCtx authNode authSchemes authorization authorizationCode authorization_code authorize autoComplete avoid await backward badgeVariants base baseDir basic be because before between bg-fd-card bg-fd-muted bg-fd-primary/10 bg-fd-secondary binary blob blue body bodyMediaType bodyNode boolean border border-b border-current border-s border-t border-y break-all buffer built-in bundled but button buttonVariants by byteLength bytes cache cached cachedDocFiles call callback callbacks callbacksNode can cannot case catch changes charset check children class-variance-authority className client clientAuth clientAuthMethods clientCredentials clientId clientSecret client_auth client_credentials client_error client_id client_secret cloned cn code codeProps codeUsages codeblock codegen codegens collapsible color com compatibility compiler component components conditions configuration const content contentType contentTypes context cookie cookies core could createClientAPIPage createCodeUsageGeneratorRegistry createContext createOpenAPIPageBase createProxy credentials css csv ctx current currentValue custom customization cva dark dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[open]:border-b-0 data-type default defaultAdapters defaultExampleId defaultItem defaultMdxComponents defaultOpen defaultShikiFactory defaultValue defaultValues default_processMarkdown definitions deprecated depth dereferenceBundledDocument dereferenceShallow dereferenced description descriptionNode development deviceAuthorization dialog didn disable disableCache disabled display displayNames div do doc docCache docFilesCache docRoot docs document documents domain downloaded dynamicSource e each else empty:hidden enabled encodeRequestData encoded endpoint enforce engine ensure entire entries entry error eslint-disable eslint-disable-next-line example exampleId exampleRequests examples export exported extends fallback false fast-content-type-parse fd-page-tree-item-name fetch fetcher field fieldName fields file filePath files fine first first:border-t-0 flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flows folder folderStyle font-medium font-mono font-normal font-semibold for form formData format found from fs full fumadocs-core/source fumadocs-core/toc fumadocs-openapi/ui fumadocs-ui/mdx fumadocs:openapi fumadocs_openapi_requests fumadocs_openapi_responses function gap-0.5 gap-1 gap-1.5 gap-2 gap-2.5 gap-24 gap-3 gap-4 gap-6 gap-x-4 gap-x-6 gap-y-1 gap-y-4 gen generate generateTypeScriptDefinitions generated generated/defined generators get getAPIPageProps getClientAPIPageProps getExampleRequests getOpenAPIPageProps getPreferredType getRaw getSchema getSchemas getWatchPaths github-dark github-light given grant_type green grid grid-cols-[auto_1fr] group group-data-[panel-open]:rotate-180 groupId h1 handling hasHead hash hast-util-to-jsx-runtime headNode header headers headingLevel highlighter hook hover:bg-fd-accent hover:text-fd-accent-foreground href html htmlFor http icon id idToTitle idx if ignore img implicit import imports in in-document info initAuthInputs initial inline-flex input inputs instanceof instances instead insteawd interface internal into is isLoading isMediaTypeSupported isRequired issues it item items items-center items-start js json json-schema-typed justify-between kept key keyof label labelVariants lang last:border-b-0 last:mb-0 latest layout lazy length let light line-through list list-disc list-inside listed listener listeners load loadDocument loaderPlugin localStorage lucide-react make map max-age may mb-1 mb-2 md mdxComponents me-auto media mediaAdapters mediaType merged message meta metaData method methodKeys mime min-w-0 modify mounted ms-auto mt-0! mt-10 mt-2 mt-3 multipart/form-data multiple must my-0! my-1.5 my-4 name name! named necessary need never new newKey no-cache node:fs node:path not not-last:pb-0 not-prose note null number oauth2 obj object of off omit on onChange onClick onCopy onOpenChange onSubmit onValueChange one only open openApiData openIdConnect openapi openapiMeta openid operation operationDescription operationId operations options or orange origin other out outline output overflow-auto overflow-hidden p p-1 p-2 p-3 packages page page-level pageData pages panelVariants param paramTypeKeys parameter parameterLabel parameterNode parameters params parent parsed parsedState parts party pass password path pathItem pathnameFromRequest payload pb-2 pe-3 persist persisted persistent place placeholder playground playgrounds please plugins pre prefix preloadOpenAPIPage preloaded prevent primary processed processor prop properties props prose-no-margin provider proxy proxyForwardCookie proxyUrl ps-2 ps-4.5 pt-1 pt-2 pt-2.5 px-1 px-2 px-3 py-0.5 py-1 py-1.5 py-2 query race raw react react-hooks/exhaustive-deps react/jsx-runtime readOnly readonly record red redirect_uri reference refs registerDefault registry rehype-react relativePath remark remark-rehype remarkGfm remarkRehype removeListener render renderAPIExampleLayout renderAPIExampleUsageTabs renderOperationLayout renderPageLayout renderParameterField renderRequestTabs renderRequestTabsDefault renderResponseTabs renderResponseTabsDefault renderWebhookLayout renderer replace request request-body requestData requestInit requestTimeout requestUrl requests required requirement requirementId requirements res reset resolvable resolve resolveMediaAdapter resolveServerUrl resolvedInput resolvedTheme resolves response response-body responseNode responseOfType responseTabs response_type responses rest result return returned returning root rounded-2xl rounded-lg rounded-md rounded-xl route s safeParse same sample satisfies scalar scan schema schemaId schemaUI schemaUIShared scheme schemeId schemes scope scopes search secondary seconds secret securities security securityEntries securityId securitySchemes segments segs select selector separator server server-to-server server-url serverSchema servers services set setClientAuth setData setExample setExampleData setIsJson setIsMounted setMounted setObjectUrl setOpen setRequirementId setSecurityId setServer setServerVariables setStore setToken setType setValue shadow-md shadow-sm shiki shikiOptions showDescription showExample showResponseSchema showTitle shrink-0 side signal single size size-3.5 size-4 slot slots sm so source spec specify spread src state staticSource status statusInfo statuses stf stfSync still storageKey storageKeys store stored string stringifyFieldKey structuredData styles submit summary supported sure switch t tab tabs testQuery text text-[0.8125rem] text-blue-600 text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-primary text-fd-secondary-foreground text-green-500 text-green-600 text-nowrap text-orange-600 text-red-400 text-red-500 text-red-600 text-sm text-start text-xs text-yellow-600 text/css text/csv text/html text/plain the their them themes this throw timeout timerRef tips title to toJsxRuntime toStaticData toc token tokenInfo token_type transform transformAuthInputs transformPageTree transition-colors tree true truncate try ts type typeof types typescript unchanged under unexpected unknown unlisted update updated updatedSchemeId updating url usage usageTabs usages use useAnchorId useApiClient useAuth useCopyButton useMemo useOnChange useOperationContext useQuery useRef useRenderContext useServerContext useState useStatusInfo useStf useStorageKey useTheme useTranslations used username using utf-8 v value values variable variables variant variants via virtual void w-14 w-fit w-full warn we webhook webhookCallbacks webhooks when whitespace-pre-wrap will with without won wrapping writeOnly x-codeSamples x-exclusiveCodeSample x-selectedCodeSample xml yellow you your");
|
|
1
|
+
@source inline("!isDefined *:data-[collapsible=true]:order-last *:min-w-0 --- --accordion-panel-height --anchor-width --available-height --available-width --collapsible-panel-height --fd-docs-row-1 --min-height --spacing --transform-origin -mode -ms-2 -mx-3 -translate-x-1/2 -translate-y-1/2 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @fuma-translate/react @fumadocs/json-schema @fumari/stf @md:grid-cols-2 @param @private @returns @scalar/api-client-react @see @typescript-eslint/no-explicit-any [&[hidden]:not([hidden='until-found'])]:hidden [&_svg]:size-3.5 a absolute accept access access_token accordion actual adapter adapters additionalProperties again against alias align allFlows allOf allow already alt always an anchor anchorIdStartsWith anchorSegments and animate-spin anyFields anyOf apiExample apiKey apiPlayground applicable application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml apply are aria-label arkdown array as asSchema async at auth auth-specific authCodeQuery authNode authSchemes authorization authorizationCode authorization_code authorize authorizes autoComplete avoid await back backdrop-blur-lg backdrop-blur-sm badgeVariants base baseDir basic be because before behavior belong bg-black/30 bg-fd-background/50 bg-fd-card bg-fd-muted bg-fd-popover bg-fd-popover/60 bg-fd-primary bg-fd-primary/10 bg-fd-secondary binary blob block blocks blue body bodyMediaType bodyNode boolean border border-b border-current border-fd-primary/20 border-s border-t border-y bottom break-all buffer built-in bundled but button buttonVariants by byteLength bytes cache cached cachedDocFiles callbacks callbacksNode can cannot case catch center change charset check children class-variance-authority className cleanup client clientAuth clientAuthMethods clientCredentials clientHeight clientId clientSecret client_auth client_credentials client_error client_id client_secret cloned closed cn code codeProps codeUsages codeblock col-span-full collapsible color compiler components configuration const content contentType contentTypes cookie cookies copying core could createContext createOpenAPIPageBase createProxy credentials css csv ctx current currentValue custom customise customization cva dark dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[closed]:animate-fd-popover-out data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-[open]:animate-fd-popover-in data-[open]:border-b-0 data-[popup-open]:text-fd-accent-foreground data-closed:animate-fd-dialog-out data-closed:animate-fd-fade-out data-collapsible data-ending-style:h-0 data-ending-style:opacity-0 data-object-search-input data-open:animate-fd-dialog-in data-open:animate-fd-fade-in data-placeholder:text-fd-muted-foreground data-starting-style:h-0 data-starting-style:opacity-0 data-type dataEngine decoded default defaultMdxComponents defaultOpen defaultShikiFactory defaultShikiOptions defaultValue defaultValues defaults deferredValue define definitions delete deprecated depth dereference dereferenced description descriptionNode development deviceAuthorization dialog didn disable disableCache disabled disabled:cursor-not-allowed disabled:opacity-50 display displayNames div do doc docCache docFilesCache docRoot docs document documents domain downloaded drives duplicated duration-200 dynamic dynamicSource e eading ease-out element else empty empty:hidden enabled encode encodeRequestData encoded end end-2 endpoint enforce engine ensure entries entry enum error eslint-disable eslint-disable-next-line example exampleId examples export exported extends fallback false fast-content-type-parse fd-page-tree-item-name fd-scroll-container fetch fetcher field fieldData fieldLabelVariants fieldName fields file filePath files filtered fine first first:border-t-0 firstItemRef fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flows focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring focus-within:[&_svg]:text-fd-primary focus-within:ring-2 focus-within:ring-fd-ring focus:outline-none focus:ring focus:ring-fd-ring folder folderStyle font-medium font-mono font-normal font-semibold for form formData format from fs full fumadocs-core/source fumadocs-core/toc fumadocs-ui/mdx fumadocs:openapi fumadocs_openapi_requests fumadocs_openapi_responses function gap-0.5 gap-1 gap-1.5 gap-2 gap-2.5 gap-24 gap-3 gap-4 gap-6 gap-x-4 gap-x-6 gap-y-1 gap-y-4 generate generateDefault generateSchemaUI generated get getOpenAPIPageProps getSchema getSchemas getWatchPaths ghost github-dark github-light given go grant_type gray green grid grid-cols-1 grid-cols-[auto_1fr] group group-data-[panel-open]/accordion:rotate-90 group-data-[panel-open]:rotate-180 group/accordion groupId h-(--accordion-panel-height) h-(--collapsible-panel-height) h-10 h-9 h-[240px] h-px h1 hash hast-util-to-jsx-runtime headNode header headers heading headingLevel headless hidden hiddenProperties highlighted highlighter holding hook hover:bg-fd-accent hover:text-fd-accent-foreground hover:underline how html htmlFor http i icon icon-sm icon-xs id idx if ignore img implicit import imports in in-popover index indexItemMatch info infoTags init initial inline-flex input inputs inset-0 inside installed instanceof instead integer interface internal into invalid is isDefined isDuplicated isDynamic isLazy isLoading isNumber isRequired issues it item items items-center items-start its j js json json-schema-typed justify-between justify-center key keyed keyof kind label labelClassName lang last last:border-b-0 last:mb-0 lazy leading-none leave left-1/2 length let light like line-through link links list list-disc list-inside listed load loadDocument loaderPlugin localStorage location lucide-react map mapValues marker:text-fd-muted-foreground matching max-age max-h-(--available-height) max-h-[460px] max-w-(--available-width) max-w-[98vw] max-w-full max-w-lg may mb-1 mb-2 mb-auto md mdxComponents me-auto media mediaType member merge mergeRefs message meta metaData method mime min-h-(--min-height,200px) min-w-0 min-w-[240px] min-w-[calc(var(--anchor-width)+--spacing(2))] modify mounted ms-auto mt-0! mt-10 mt-2 mt-3 multipart/form-data multiple must mx-1 my-0! my-1 my-1.5 my-2 my-2! my-4 name name! named namespace navigating navigation need needs nested never new no no-cache node node:fs node:path not not-last:pb-0 not-prose note null number oauth2 object objectSearchOverrides objectSet objects of off omit on onChange onClick onCopy onKeyDown onOpenChange onScrollEnd onSubmit onValueChange one oneOf ones only opacity-80 open openApiData openIdConnect openapi openapiMeta opened opens operation options or orange order-last origin origin-(--transform-origin) other out outline outline-none output over overflow-auto overflow-hidden overflow-x-auto overflow-y-auto overflow-y-hidden p-1 p-1.5 p-2 p-3 p-4 packages page pageData pages panelVariants param parameter parameterLabel parameterNode parameters params parent parentPathIndex parents parsed parsedState part parts party pass password path pathIndex pathItem pathName pathnameFromRequest pattern patternProperties payload pb-0 pb-2 pe-2 pe-3 peer-disabled:cursor-not-allowed peer-disabled:opacity-70 persist persisted picked place placeholder placeholder:text-fd-muted-foreground playground playgrounds please plugins popover popoverRef positions pre preloadOpenAPIPage preloaded preventScroll previous primitive processor properties property props prose prose-no-margin prose-sm proxy proxyForwardCookie proxyUrl ps-1 ps-2 ps-3 ps-4.5 ps-6 pt-0 pt-1 pt-2 pt-2.5 px px-1 px-2 px-3 px-4 py-0 py-0.5 py-1 py-1.5 py-2 py-4 query querySelector quiet raw rawSearch re-triggering react react-hooks/exhaustive-deps react/jsx-runtime read readOnly readonly record red redirect_uri ref reference refs regenerated rehype-react relativePath remark remark-rehype remarkGfm remarkRehype remove removeItem removing render renderBodyField renderCodeblock renderMarkdown renderParameterField renderPopoverTrigger renderTrigger rendered renderers renders replace represents request request-body requestBody requestData requestInit requestTimeout requestUrl requests required requirement requirements res reset resize-none resolve resolveMediaAdapter resolveUrl resolved resolvedInput resolvedTheme response response-body responseNode responseTabs response_type responses rest restored result return returning returns role root rootId roots rotate-90 rounded-2xl rounded-lg rounded-md rounded-sm rounded-xl route s-highlight safeParse same satisfies scalar scan schema schemaId schemaPropKeys schemaUI scheme schemeId schemes scope scopes scroll scroll-m-20 scrollTop scrollTops search secondary seconds secret section sections security segments segs select select-none selected selectedType selections selector sends sep separator server server-to-server serverSchema services set setClientAuth setError setInfo setIsJson setIsMounted setMounted setNextName setObjectUrl setOpen setPath setSearch setSelected setServerVariables setShow setStore setToken setType setValue shadow-lg shadow-md shadow-sm shared shiki shikiOptions show showDescription showExample showResponseSchema showSelect showTitle showing shrink-0 side sideOffset signal single size size-3.5 size-4 skipNonRequired skipReadOnly slot slotType slots sm sm:flex-row sm:gap-2 sm:justify-end sm:text-start smooth so source specify src stable start state staticSource status statusInfo step stf stfSync sticky still storageKey store stored string stringify stringifyFieldKey structuredData styles submit such supported svg switch t tab tabDepth tabValues tabs tag target testQuery text text-[0.8125rem] text-blue-600 text-center text-end text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-secondary-foreground text-green-500 text-green-600 text-lg text-nowrap text-orange-400 text-orange-600 text-red-400 text-red-400/80 text-red-500 text-red-600 text-sm text-start text-xs text-yellow-600 text/css text/csv text/html text/plain that the their them themes they this through throw timeout timerRef tips title to toJsxRuntime toStaticData toc token tokenInfo tokenUrl token_type toolbar top top-0 top-1/2 top-10 top-2 tracking-tight transform transformPageTree transition-[height,opacity] transition-[height] transition-colors transition-transform translations tree trigger true truncate try ts type typeVariants typeof types unchanged undefined under underline unexpected union unionField unions unknown unlisted unselected up update updateInfo updated updatedSchemeId updating url usageTabs use useAnchorId useApiClient useComponents useCopyButton useFieldValue useListener useMemo useNamespace useObject useOnChange useOpenAPI useOperation usePlaygroundAuth useQuery useRef useRenderContext useResponseExamples useServer useState useStatusInfo useStf useTheme useTranslations useTypeScriptDefinitions used username using utf-8 v value valueSchema values variable variables variant variants via view virtual void w-0 w-14 w-[600px] w-fit w-full warn was we webhook webhooks when where whitespace-pre-wrap will with without won wrap-break-word wrapping write writeOnly x-exclusiveCodeSample x-playground-lazy xml yellow you your z-20 z-50");
|
package/css/preset.css
CHANGED
|
@@ -6,6 +6,15 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
9
18
|
var __copyProps = (to, from, except, desc) => {
|
|
10
19
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
20
|
key = keys[i];
|
|
@@ -21,4 +30,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
30
|
enumerable: true
|
|
22
31
|
}) : target, mod));
|
|
23
32
|
//#endregion
|
|
24
|
-
export { __commonJSMin, __toESM };
|
|
33
|
+
export { __commonJSMin, __exportAll, __toESM };
|
package/dist/generate-file.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { DistributiveOmit } from "./types.js";
|
|
1
2
|
import { OutputEntry } from "./utils/pages/builder.js";
|
|
2
3
|
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
3
|
-
import { OpenAPIServer } from "./server/index.js";
|
|
4
|
-
import { DistributiveOmit } from "./types.js";
|
|
5
4
|
import { PagesToTextOptions } from "./utils/pages/to-text.js";
|
|
5
|
+
import { OpenAPIServer } from "./server/index.js";
|
|
6
6
|
//#region src/generate-file.d.ts
|
|
7
7
|
export interface OutputFile {
|
|
8
8
|
path: string;
|
package/dist/generate-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fromSchema } from "./utils/pages/builder.js";
|
|
2
1
|
import { doubleQuote } from "./requests/string-utils.js";
|
|
2
|
+
import { fromSchema } from "./utils/pages/builder.js";
|
|
3
3
|
import { generateDocument, toText } from "./utils/pages/to-text.js";
|
|
4
4
|
import { createAutoPreset } from "./utils/pages/preset-auto.js";
|
|
5
5
|
import { mkdir, writeFile } from "node:fs/promises";
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Translations } from "./.translations/index.js";
|
|
2
|
-
import { Translations as Translations$
|
|
1
|
+
import { Translations as Translations$1 } from "./.translations/index.js";
|
|
2
|
+
import { Translations as Translations$2 } from "./packages/shared-api/dist/.translations/index.js";
|
|
3
|
+
import "./packages/shared-api/dist/i18n.js";
|
|
3
4
|
import { TranslationExtension } from "fumadocs-core/i18n";
|
|
4
|
-
import { I18nUIConfig } from "fumadocs-ui/i18n";
|
|
5
5
|
//#region src/i18n.d.ts
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export type { Translations };
|
|
6
|
+
export type Translations = Translations$1 & Translations$2;
|
|
7
|
+
export declare function openapiTranslations(): TranslationExtension<keyof Translations>;
|
|
8
|
+
//#endregion
|
package/dist/i18n.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import keys_default from "./.translations/keys.js";
|
|
2
|
-
import { apiDocsTranslations } from "
|
|
2
|
+
import { apiDocsTranslations } from "./packages/shared-api/dist/i18n.js";
|
|
3
3
|
//#region src/i18n.ts
|
|
4
4
|
function openapiTranslations() {
|
|
5
5
|
return { keys: [...apiDocsTranslations().keys, ...keys_default] };
|
|
6
6
|
}
|
|
7
|
-
/** @deprecated use `i18n.translations()` & `openapiTranslations()` instead */
|
|
8
|
-
function defineI18nOpenAPI(config, translations) {
|
|
9
|
-
return {
|
|
10
|
-
...config,
|
|
11
|
-
provider(locale = config.defaultLanguage) {
|
|
12
|
-
const out = config.provider(locale);
|
|
13
|
-
const data = translations[locale];
|
|
14
|
-
if (data) out.translations = {
|
|
15
|
-
...out.translations,
|
|
16
|
-
...data
|
|
17
|
-
};
|
|
18
|
-
return out;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
7
|
//#endregion
|
|
23
|
-
export {
|
|
8
|
+
export { openapiTranslations };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from "./types/openapi.js";
|
|
2
|
+
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
3
|
+
import { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject } from "./types.js";
|
|
4
|
+
import { GeneratedPageProps, OperationItem, OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookItem, WebhookOutput } from "./utils/pages/builder.js";
|
|
5
|
+
import { CodeBlockProps } from "./packages/shared-api/dist/components/defaults.js";
|
|
6
|
+
import { APIPlaygroundProps, CreateOpenAPIRendererOptions, GenerateTypeScriptDefinitionsContext, OpenAPIComponents, OpenAPIRenderOptions, OpenAPIRuntime, OpenAPIRuntimeOptions, OperationPlaygroundOptions, PageLayoutProps, RenderContext, createOpenAPIBaseRenderer, createOpenAPIRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions } from "./utils/create-page.js";
|
|
7
|
+
import { SelectedServer, useServer } from "./utils/use-server.js";
|
|
8
|
+
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
9
|
+
//#region src/index.browser.d.ts
|
|
10
|
+
export declare function generateFiles(): Promise<void>;
|
|
11
|
+
export declare function generateFilesOnly(): Promise<never>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { APIPlaygroundProps, type Awaitable, type CallbackObject, type CodeBlockProps, CreateOpenAPIRendererOptions, type DistributiveOmit, type Document, type ExampleObject, GenerateTypeScriptDefinitionsContext, type GeneratedPageProps, type HttpMethods, type MediaAdapter, type MediaTypeObject, type OAuth2SecurityScheme, type OpenAPI, OpenAPIComponents, OpenAPIRenderOptions, OpenAPIRuntime, OpenAPIRuntimeOptions, type OpenAPIV2, type OpenAPIV3, type OpenAPIV3_1, type OpenAPIV3_2, type OperationItem, type OperationObject, type OperationOutput, OperationPlaygroundOptions, type OutputEntry, type OutputGroup, PageLayoutProps, type PageOutput, type PagesBuilder, type PagesBuilderConfig, type ParameterObject, type PathItemObject, type ReferenceObject, RenderContext, type RequestBodyObject, type ResponseObject, type SchemaToPagesOptions, type SecuritySchemeObject, type SelectedServer, type ServerObject, type ServerVariableObject, type TagObject, type WebhookItem, type WebhookOutput, createOpenAPIBaseRenderer, createOpenAPIRenderer, useComponents, useOpenAPI, useRenderContext, useServer, useTypeScriptDefinitions };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useServer } from "./utils/use-server.js";
|
|
2
|
+
import { createOpenAPIBaseRenderer, createOpenAPIRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions } from "./utils/create-page.js";
|
|
3
|
+
//#region src/index.browser.ts
|
|
4
|
+
async function generateFiles() {
|
|
5
|
+
throw new Error("`generateFiles` is only available on Node.js.");
|
|
6
|
+
}
|
|
7
|
+
async function generateFilesOnly() {
|
|
8
|
+
throw new Error("`generateFilesOnly` is only available on Node.js.");
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createOpenAPIBaseRenderer, createOpenAPIRenderer, generateFiles, generateFilesOnly, useComponents, useOpenAPI, useRenderContext, useServer, useTypeScriptDefinitions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from "./types/openapi.js";
|
|
2
2
|
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
3
|
+
import { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject } from "./types.js";
|
|
3
4
|
import { GeneratedPageProps, OperationItem, OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookItem, WebhookOutput } from "./utils/pages/builder.js";
|
|
5
|
+
import { CodeBlockProps } from "./packages/shared-api/dist/components/defaults.js";
|
|
6
|
+
import { APIPlaygroundProps, CreateOpenAPIRendererOptions, GenerateTypeScriptDefinitionsContext, OpenAPIComponents, OpenAPIRenderOptions, OpenAPIRuntime, OpenAPIRuntimeOptions, OperationPlaygroundOptions, PageLayoutProps, RenderContext, createOpenAPIBaseRenderer, createOpenAPIRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions } from "./utils/create-page.js";
|
|
7
|
+
import { SelectedServer, useServer } from "./utils/use-server.js";
|
|
4
8
|
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
5
|
-
import { Awaitable, CallbackObject, DistributiveOmit, Document, ExampleObject, HttpMethods, MediaTypeObject, OAuth2SecurityScheme, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, RequestBodyObject, ResponseObject, SecuritySchemeObject, ServerObject, ServerVariableObject, TagObject } from "./types.js";
|
|
6
9
|
import { Config, OutputFile, generateFiles, generateFilesOnly } from "./generate-file.js";
|
|
7
|
-
export { type Awaitable, type CallbackObject, Config, type DistributiveOmit, type Document, type ExampleObject, type GeneratedPageProps, type HttpMethods, type MediaAdapter, type MediaTypeObject, type OAuth2SecurityScheme, type OpenAPI, type OpenAPIV2, type OpenAPIV3, type OpenAPIV3_1, type OpenAPIV3_2, type OperationItem, type OperationObject, type OperationOutput, type OutputEntry, OutputFile, type OutputGroup, type PageOutput, type PagesBuilder, type PagesBuilderConfig, type ParameterObject, type PathItemObject, type ReferenceObject,
|
|
10
|
+
export { APIPlaygroundProps, type Awaitable, type CallbackObject, type CodeBlockProps, Config, CreateOpenAPIRendererOptions, type DistributiveOmit, type Document, type ExampleObject, GenerateTypeScriptDefinitionsContext, type GeneratedPageProps, type HttpMethods, type MediaAdapter, type MediaTypeObject, type OAuth2SecurityScheme, type OpenAPI, OpenAPIComponents, OpenAPIRenderOptions, OpenAPIRuntime, OpenAPIRuntimeOptions, type OpenAPIV2, type OpenAPIV3, type OpenAPIV3_1, type OpenAPIV3_2, type OperationItem, type OperationObject, type OperationOutput, OperationPlaygroundOptions, type OutputEntry, OutputFile, type OutputGroup, PageLayoutProps, type PageOutput, type PagesBuilder, type PagesBuilderConfig, type ParameterObject, type PathItemObject, type ReferenceObject, RenderContext, type RequestBodyObject, type ResponseObject, type SchemaToPagesOptions, type SecuritySchemeObject, type SelectedServer, type ServerObject, type ServerVariableObject, type TagObject, type WebhookItem, type WebhookOutput, createOpenAPIBaseRenderer, createOpenAPIRenderer, generateFiles, generateFilesOnly, useComponents, useOpenAPI, useRenderContext, useServer, useTypeScriptDefinitions };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { useServer } from "./utils/use-server.js";
|
|
2
|
+
import { createOpenAPIBaseRenderer, createOpenAPIRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions } from "./utils/create-page.js";
|
|
1
3
|
import { generateFiles, generateFilesOnly } from "./generate-file.js";
|
|
2
|
-
export { generateFiles, generateFilesOnly };
|
|
4
|
+
export { createOpenAPIBaseRenderer, createOpenAPIRenderer, generateFiles, generateFilesOnly, useComponents, useOpenAPI, useRenderContext, useServer, useTypeScriptDefinitions };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { RawRequestData, RequestData } from "./requests/types.js";
|
|
2
|
+
import { CodeUsageGeneratorRegistry } from "./requests/generators/index.js";
|
|
3
|
+
import { HttpMethods, MediaTypeObject, OperationObject, ParameterObject, PathItemObject, ResponseObject, SecuritySchemeObject } from "./types.js";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
//#region src/operation.d.ts
|
|
6
|
+
export interface OperationParameters {
|
|
7
|
+
in: 'path' | 'query' | 'header' | 'cookie';
|
|
8
|
+
items: ParameterObject[];
|
|
9
|
+
}
|
|
10
|
+
export interface OperationSecurity {
|
|
11
|
+
key: string;
|
|
12
|
+
scopes: string[];
|
|
13
|
+
/** `undefined` when the document doesn't define the scheme */
|
|
14
|
+
scheme?: SecuritySchemeObject;
|
|
15
|
+
}
|
|
16
|
+
export interface OperationResponse {
|
|
17
|
+
status: string;
|
|
18
|
+
response: ResponseObject;
|
|
19
|
+
/** media types of the response, resolved */
|
|
20
|
+
content: Record<string, MediaTypeObject>;
|
|
21
|
+
}
|
|
22
|
+
export interface OperationCallback {
|
|
23
|
+
name: string;
|
|
24
|
+
path: string;
|
|
25
|
+
method: HttpMethods;
|
|
26
|
+
pathItem: PathItemObject;
|
|
27
|
+
operation: OperationObject;
|
|
28
|
+
}
|
|
29
|
+
/** the operation and its resolved details, all read-only */
|
|
30
|
+
export interface OperationInfo {
|
|
31
|
+
type: 'operation' | 'webhook';
|
|
32
|
+
path: string;
|
|
33
|
+
method: HttpMethods;
|
|
34
|
+
operation: OperationObject;
|
|
35
|
+
pathItem: PathItemObject;
|
|
36
|
+
title: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
/** resolved request body with its media types, `undefined` when it has none */
|
|
39
|
+
requestBody?: {
|
|
40
|
+
description?: string;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
content: Record<string, MediaTypeObject>;
|
|
43
|
+
};
|
|
44
|
+
/** resolved parameters grouped by location, empty groups omitted */
|
|
45
|
+
parameters: OperationParameters[];
|
|
46
|
+
/** alternative security requirements, always empty for webhooks */
|
|
47
|
+
security: OperationSecurity[][];
|
|
48
|
+
responses: OperationResponse[];
|
|
49
|
+
/** callbacks flattened into webhook operations */
|
|
50
|
+
callbacks: OperationCallback[];
|
|
51
|
+
/** code usage generators, including the inline code samples of operation */
|
|
52
|
+
codeUsages: CodeUsageGeneratorRegistry;
|
|
53
|
+
}
|
|
54
|
+
export interface ExampleRequest {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
data: RawRequestData;
|
|
59
|
+
encoded: RequestData;
|
|
60
|
+
/** pathname of the request, with path parameters and query encoded */
|
|
61
|
+
pathname: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ResponseExample {
|
|
64
|
+
/**
|
|
65
|
+
* generated/defined example data
|
|
66
|
+
*/
|
|
67
|
+
sample: unknown;
|
|
68
|
+
label: ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* description (in Markdown)
|
|
71
|
+
*/
|
|
72
|
+
description?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ResponseTab {
|
|
75
|
+
/**
|
|
76
|
+
* HTTP response code
|
|
77
|
+
*/
|
|
78
|
+
code: string;
|
|
79
|
+
response: ResponseObject;
|
|
80
|
+
/**
|
|
81
|
+
* media type of response
|
|
82
|
+
*/
|
|
83
|
+
mediaType: string | null;
|
|
84
|
+
examples?: ResponseExample[];
|
|
85
|
+
}
|
|
86
|
+
/** props of the component rendering an operation or webhook of a page */
|
|
87
|
+
export interface PageOperationProps {
|
|
88
|
+
type: 'operation' | 'webhook';
|
|
89
|
+
path: string;
|
|
90
|
+
method: HttpMethods;
|
|
91
|
+
operation: OperationObject;
|
|
92
|
+
pathItem: PathItemObject;
|
|
93
|
+
showTitle?: boolean;
|
|
94
|
+
showDescription?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface OperationProviderProps {
|
|
97
|
+
/** @defaultValue 'operation' */
|
|
98
|
+
type?: 'operation' | 'webhook';
|
|
99
|
+
path: string;
|
|
100
|
+
method: HttpMethods;
|
|
101
|
+
operation: OperationObject;
|
|
102
|
+
pathItem: PathItemObject;
|
|
103
|
+
children: ReactNode;
|
|
104
|
+
}
|
|
105
|
+
export declare function OperationProvider({ type, path, method, operation, pathItem, children }: OperationProviderProps): import("react").JSX.Element;
|
|
106
|
+
export declare function useOperation(): OperationInfo;
|
|
107
|
+
/**
|
|
108
|
+
* Example requests of the operation, and the selected one.
|
|
109
|
+
*
|
|
110
|
+
* It doesn't follow the updates of items, use `useExampleRequest()` for the data of selected one.
|
|
111
|
+
*/
|
|
112
|
+
export declare function useExampleRequests(): {
|
|
113
|
+
items: ExampleRequest[];
|
|
114
|
+
selected: string | undefined;
|
|
115
|
+
select: (id: string) => void;
|
|
116
|
+
/** update the data of selected example */
|
|
117
|
+
update: (data: RawRequestData) => void;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Data of the selected example request, following its updates.
|
|
121
|
+
*/
|
|
122
|
+
export declare function useExampleRequest(): RawRequestData | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Generate the code usage of the selected example request with the generator `id`.
|
|
125
|
+
*
|
|
126
|
+
* @returns `undefined` when the generator or the example is unavailable
|
|
127
|
+
*/
|
|
128
|
+
export declare function useCodeUsage(id: string): string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Responses of the operation, with example values of their preferred media type.
|
|
131
|
+
*/
|
|
132
|
+
export declare function useResponseExamples(): ResponseTab[];
|
|
133
|
+
//#endregion
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isMediaTypeSupported } from "./requests/media/resolve-adapter.js";
|
|
3
|
+
import { createCodeUsageGeneratorRegistry, pathnameFromRequest } from "./requests/generators/index.js";
|
|
4
|
+
import { joinURL } from "./packages/shared-api/dist/utils/url.js";
|
|
5
|
+
import { ServerProvider, useServer } from "./utils/use-server.js";
|
|
6
|
+
import { useOpenAPI } from "./utils/create-page.js";
|
|
7
|
+
import { idToTitle } from "./packages/shared-api/dist/utils/id-to-title.js";
|
|
8
|
+
import { getPreferredType, methodKeys } from "./utils/schema.js";
|
|
9
|
+
import { encodeRequestData } from "./requests/media/encode.js";
|
|
10
|
+
import { getExampleRequests } from "./utils/get-example-requests.js";
|
|
11
|
+
import { createContext, use, useMemo, useSyncExternalStore } from "react";
|
|
12
|
+
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
13
|
+
import { sample } from "@fumadocs/json-schema";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
16
|
+
//#region src/operation.tsx
|
|
17
|
+
const OperationContext = createContext(null);
|
|
18
|
+
const parameterLocations = [
|
|
19
|
+
"path",
|
|
20
|
+
"query",
|
|
21
|
+
"header",
|
|
22
|
+
"cookie"
|
|
23
|
+
];
|
|
24
|
+
function OperationProvider({ type = "operation", path, method, operation, pathItem, children }) {
|
|
25
|
+
const runtime = useOpenAPI();
|
|
26
|
+
const state = useMemo(() => {
|
|
27
|
+
const { dereferenced, resolve } = runtime.doc;
|
|
28
|
+
const body = resolve(operation.requestBody);
|
|
29
|
+
let requestBody;
|
|
30
|
+
if (body?.content && Object.keys(body.content).length > 0) {
|
|
31
|
+
const content = {};
|
|
32
|
+
for (const [mediaType, item] of Object.entries(body.content)) {
|
|
33
|
+
if (!isMediaTypeSupported(mediaType, runtime.mediaAdapters)) throw new Error(`Media type ${mediaType} is not supported (in ${path})`);
|
|
34
|
+
content[mediaType] = resolve(item);
|
|
35
|
+
}
|
|
36
|
+
requestBody = {
|
|
37
|
+
description: body.description,
|
|
38
|
+
required: body.required,
|
|
39
|
+
content
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const resolvedParameters = [];
|
|
43
|
+
const groups = {};
|
|
44
|
+
const keys = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const list of [operation.parameters, pathItem.parameters]) for (const item of list ?? []) {
|
|
46
|
+
const param = resolve(item);
|
|
47
|
+
const key = `${param.in}:${param.name}`;
|
|
48
|
+
if (keys.has(key)) continue;
|
|
49
|
+
keys.add(key);
|
|
50
|
+
resolvedParameters.push(param);
|
|
51
|
+
(groups[param.in] ??= []).push(param);
|
|
52
|
+
}
|
|
53
|
+
const parameters = [];
|
|
54
|
+
for (const location of parameterLocations) {
|
|
55
|
+
const items = groups[location];
|
|
56
|
+
if (items) parameters.push({
|
|
57
|
+
in: location,
|
|
58
|
+
items
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const security = [];
|
|
62
|
+
if (type === "operation") {
|
|
63
|
+
const schemes = dereferenced.components?.securitySchemes;
|
|
64
|
+
for (const requirement of operation.security ?? dereferenced.security ?? []) {
|
|
65
|
+
const entries = Object.entries(requirement);
|
|
66
|
+
if (entries.length === 0) continue;
|
|
67
|
+
security.push(entries.map(([key, scopes]) => ({
|
|
68
|
+
key,
|
|
69
|
+
scopes,
|
|
70
|
+
scheme: resolve(schemes?.[key])
|
|
71
|
+
})));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const responses = [];
|
|
75
|
+
for (const [status, item] of Object.entries(operation.responses ?? {})) {
|
|
76
|
+
const response = resolve(item);
|
|
77
|
+
const content = {};
|
|
78
|
+
for (const [mediaType, media] of Object.entries(response.content ?? {})) content[mediaType] = resolve(media);
|
|
79
|
+
responses.push({
|
|
80
|
+
status,
|
|
81
|
+
response,
|
|
82
|
+
content
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const callbacks = [];
|
|
86
|
+
for (const [name, item] of Object.entries(operation.callbacks ?? {})) for (const [callbackPath, rawPathItem] of Object.entries(resolve(item))) {
|
|
87
|
+
const callback = resolve(rawPathItem);
|
|
88
|
+
for (const callbackMethod of methodKeys) {
|
|
89
|
+
const callbackOperation = callback[callbackMethod];
|
|
90
|
+
if (!callbackOperation) continue;
|
|
91
|
+
callbacks.push({
|
|
92
|
+
name,
|
|
93
|
+
path: callbackPath,
|
|
94
|
+
method: callbackMethod,
|
|
95
|
+
pathItem: callback,
|
|
96
|
+
operation: callbackOperation
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const codeUsages = createCodeUsageGeneratorRegistry(runtime.codeUsages);
|
|
101
|
+
if (type === "operation") {
|
|
102
|
+
for (const gen of runtime.generateCodeSamples?.({
|
|
103
|
+
path,
|
|
104
|
+
operation,
|
|
105
|
+
method,
|
|
106
|
+
pathItem
|
|
107
|
+
}) ?? []) codeUsages.addInline(gen);
|
|
108
|
+
for (const inline of operation["x-codeSamples"] ?? []) codeUsages.addInline(inline);
|
|
109
|
+
}
|
|
110
|
+
const examples = getExampleRequests({
|
|
111
|
+
path,
|
|
112
|
+
method,
|
|
113
|
+
operation,
|
|
114
|
+
parameters: resolvedParameters,
|
|
115
|
+
mediaAdapters: runtime.mediaAdapters
|
|
116
|
+
});
|
|
117
|
+
for (const item of examples) item.pathname = pathnameFromRequest(path, item.encoded);
|
|
118
|
+
return {
|
|
119
|
+
info: {
|
|
120
|
+
type,
|
|
121
|
+
path,
|
|
122
|
+
method,
|
|
123
|
+
operation,
|
|
124
|
+
pathItem,
|
|
125
|
+
title: operation.summary || pathItem.summary || (operation.operationId ? idToTitle(operation.operationId) : path),
|
|
126
|
+
description: operation.description ?? pathItem.description,
|
|
127
|
+
requestBody,
|
|
128
|
+
parameters,
|
|
129
|
+
security,
|
|
130
|
+
responses,
|
|
131
|
+
callbacks,
|
|
132
|
+
codeUsages
|
|
133
|
+
},
|
|
134
|
+
parameters: resolvedParameters,
|
|
135
|
+
examples,
|
|
136
|
+
...createExampleStore(examples, operation["x-exclusiveCodeSample"] ?? operation["x-selectedCodeSample"] ?? examples[0]?.id, path, (data) => encodeRequestData(data, runtime.mediaAdapters, resolvedParameters))
|
|
137
|
+
};
|
|
138
|
+
}, [
|
|
139
|
+
runtime,
|
|
140
|
+
type,
|
|
141
|
+
path,
|
|
142
|
+
method,
|
|
143
|
+
operation,
|
|
144
|
+
pathItem
|
|
145
|
+
]);
|
|
146
|
+
const content = /* @__PURE__ */ jsx(OperationContext, {
|
|
147
|
+
value: state,
|
|
148
|
+
children
|
|
149
|
+
});
|
|
150
|
+
const servers = operation.servers ?? pathItem.servers;
|
|
151
|
+
if (!servers) return content;
|
|
152
|
+
return /* @__PURE__ */ jsx(ServerProvider, {
|
|
153
|
+
servers,
|
|
154
|
+
storageKeyPrefix: runtime.storageKeyPrefix,
|
|
155
|
+
children: content
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** an external store, so selecting examples doesn't re-render the entire operation */
|
|
159
|
+
function createExampleStore(examples, selected, path, encode) {
|
|
160
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
161
|
+
function notify(item) {
|
|
162
|
+
for (const listener of listeners) listener(item);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
getExample: () => selected,
|
|
166
|
+
setExample(id) {
|
|
167
|
+
const item = examples.find((item) => item.id === id);
|
|
168
|
+
if (!item) return;
|
|
169
|
+
selected = id;
|
|
170
|
+
notify(item);
|
|
171
|
+
},
|
|
172
|
+
update(data, encoded = encode(data)) {
|
|
173
|
+
const item = examples.find((item) => item.id === selected);
|
|
174
|
+
if (!item) return;
|
|
175
|
+
item.data = data;
|
|
176
|
+
item.encoded = encoded;
|
|
177
|
+
item.pathname = pathnameFromRequest(path, encoded);
|
|
178
|
+
notify(item);
|
|
179
|
+
},
|
|
180
|
+
subscribe(listener) {
|
|
181
|
+
listeners.add(listener);
|
|
182
|
+
return () => {
|
|
183
|
+
listeners.delete(listener);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function useOperationState() {
|
|
189
|
+
const ctx = use(OperationContext);
|
|
190
|
+
if (!ctx) throw new Error("Component must be used under <OperationProvider />");
|
|
191
|
+
return ctx;
|
|
192
|
+
}
|
|
193
|
+
function useOperation() {
|
|
194
|
+
return useOperationState().info;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Example requests of the operation, and the selected one.
|
|
198
|
+
*
|
|
199
|
+
* It doesn't follow the updates of items, use `useExampleRequest()` for the data of selected one.
|
|
200
|
+
*/
|
|
201
|
+
function useExampleRequests() {
|
|
202
|
+
const { examples, getExample, setExample, update, subscribe } = useOperationState();
|
|
203
|
+
return {
|
|
204
|
+
items: examples,
|
|
205
|
+
selected: useSyncExternalStore(subscribe, getExample, getExample),
|
|
206
|
+
select: setExample,
|
|
207
|
+
update
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function useSelectedExample() {
|
|
211
|
+
const { examples, getExample, subscribe } = useOperationState();
|
|
212
|
+
const getSnapshot = () => examples.find((item) => item.id === getExample())?.encoded;
|
|
213
|
+
const encoded = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
214
|
+
return examples.find((item) => item.encoded === encoded);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Data of the selected example request, following its updates.
|
|
218
|
+
*/
|
|
219
|
+
function useExampleRequest() {
|
|
220
|
+
return useSelectedExample()?.data;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Generate the code usage of the selected example request with the generator `id`.
|
|
224
|
+
*
|
|
225
|
+
* @returns `undefined` when the generator or the example is unavailable
|
|
226
|
+
*/
|
|
227
|
+
function useCodeUsage(id) {
|
|
228
|
+
const { mediaAdapters } = useOpenAPI();
|
|
229
|
+
const { info } = useOperationState();
|
|
230
|
+
const { server, resolveUrl } = useServer();
|
|
231
|
+
const codegen = info.codeUsages.get(id);
|
|
232
|
+
const { encoded, pathname } = useSelectedExample() ?? {};
|
|
233
|
+
return useMemo(() => {
|
|
234
|
+
if (!encoded || !pathname || !codegen) return;
|
|
235
|
+
return codegen.generate({
|
|
236
|
+
...encoded,
|
|
237
|
+
url: server ? resolveUrl(pathname) : joinURL("https://example.com", pathname)
|
|
238
|
+
}, {
|
|
239
|
+
mediaAdapters,
|
|
240
|
+
custom: null
|
|
241
|
+
});
|
|
242
|
+
}, [
|
|
243
|
+
encoded,
|
|
244
|
+
pathname,
|
|
245
|
+
server,
|
|
246
|
+
resolveUrl,
|
|
247
|
+
codegen,
|
|
248
|
+
mediaAdapters
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Responses of the operation, with example values of their preferred media type.
|
|
253
|
+
*/
|
|
254
|
+
function useResponseExamples() {
|
|
255
|
+
const { responses } = useOperation();
|
|
256
|
+
const { resolve } = useOpenAPI().doc;
|
|
257
|
+
const t = useTranslations({ note: "operation page" });
|
|
258
|
+
return useMemo(() => {
|
|
259
|
+
const tabs = [];
|
|
260
|
+
for (const { status: code, response, content } of responses) {
|
|
261
|
+
const media = getPreferredType(content) ?? null;
|
|
262
|
+
const responseOfType = media ? content[media] : null;
|
|
263
|
+
const tab = {
|
|
264
|
+
code,
|
|
265
|
+
response,
|
|
266
|
+
mediaType: media
|
|
267
|
+
};
|
|
268
|
+
if (responseOfType?.examples) {
|
|
269
|
+
tab.examples = [];
|
|
270
|
+
for (const [key, item] of Object.entries(responseOfType.examples)) {
|
|
271
|
+
const example = resolve(item);
|
|
272
|
+
tab.examples.push({
|
|
273
|
+
label: example.summary ?? t("Example {key}", { variables: { key } }),
|
|
274
|
+
sample: getRaw(example.value),
|
|
275
|
+
description: example.description
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
} else if (responseOfType?.example !== void 0) tab.examples = [{
|
|
279
|
+
label: t("Example"),
|
|
280
|
+
sample: getRaw(responseOfType.example)
|
|
281
|
+
}];
|
|
282
|
+
else if (responseOfType?.schema) tab.examples = [{
|
|
283
|
+
label: t("Example"),
|
|
284
|
+
sample: sample(responseOfType.schema)
|
|
285
|
+
}];
|
|
286
|
+
tabs.push(tab);
|
|
287
|
+
}
|
|
288
|
+
return tabs;
|
|
289
|
+
}, [
|
|
290
|
+
responses,
|
|
291
|
+
resolve,
|
|
292
|
+
t
|
|
293
|
+
]);
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
export { OperationProvider, useCodeUsage, useExampleRequest, useExampleRequests, useOperation, useResponseExamples };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region ../shared-api/dist/.translations/index.d.ts
|
|
2
|
+
//#region src/.translations/index.d.ts
|
|
3
|
+
export type Translations = {
|
|
4
|
+
"Default(schema UI)": string;
|
|
5
|
+
"Deprecated(schema UI)": string;
|
|
6
|
+
"Enter Property Name(playground)": string;
|
|
7
|
+
"Enter value(playground)": string;
|
|
8
|
+
"Example(schema UI)": string;
|
|
9
|
+
"Filter Properties(schema UI)": string;
|
|
10
|
+
"Format(schema UI)": string;
|
|
11
|
+
"Items(schema UI)": string;
|
|
12
|
+
"Length(schema UI)": string;
|
|
13
|
+
"Match(schema UI)": string;
|
|
14
|
+
"Multiple Of(schema UI)": string;
|
|
15
|
+
"New Item(playground)": string;
|
|
16
|
+
"New(playground)": string;
|
|
17
|
+
"No property matching(schema UI)": string;
|
|
18
|
+
"Properties(schema UI)": string;
|
|
19
|
+
"Range(schema UI)": string;
|
|
20
|
+
"Remove Item(playground)(aria-label)": string;
|
|
21
|
+
"Select(playground)": string;
|
|
22
|
+
"Selected(playground)": string;
|
|
23
|
+
"Show Property(playground)": string;
|
|
24
|
+
"Unset(playground)": string;
|
|
25
|
+
"Upload(playground)": string;
|
|
26
|
+
"Value in(schema UI)": string;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#endregion
|