fumadocs-openapi 12.3.0 → 12.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/dist/.translations/index.d.ts +3 -1
- package/dist/.translations/keys.js +3 -1
- package/dist/operation.js +4 -4
- package/dist/packages/shared-api/dist/components/defaults.js +1 -1
- package/dist/playground/auth.d.ts +61 -7
- package/dist/playground/auth.js +192 -95
- package/dist/playground/fetcher.d.ts +1 -1
- package/dist/playground/index.d.ts +2 -2
- package/dist/playground/index.js +2 -2
- package/dist/playground/use-playground.d.ts +5 -3
- package/dist/playground/use-playground.js +22 -10
- package/dist/requests/generators/csharp.js +11 -21
- package/dist/requests/generators/curl.js +12 -14
- package/dist/requests/generators/go.js +22 -33
- package/dist/requests/generators/index.d.ts +1 -1
- package/dist/requests/generators/java.js +33 -37
- package/dist/requests/generators/javascript.js +13 -20
- package/dist/requests/generators/python.js +12 -17
- package/dist/requests/generators/rust.js +15 -20
- package/dist/requests/index.d.ts +1 -1
- package/dist/requests/media/adapter.d.ts +0 -1
- package/dist/requests/media/adapter.js +50 -42
- package/dist/requests/media/encode.d.ts +1 -1
- package/dist/requests/media/encode.js +1 -1
- package/dist/requests/string-utils.js +14 -6
- package/dist/ui/operation/index.js +1 -1
- package/dist/ui/operation/request-tabs.js +1 -1
- package/dist/ui/operation/response-tabs.js +1 -1
- package/dist/ui/operation/usage-tabs.js +1 -1
- package/dist/ui/playground/client.d.ts +1 -1
- package/dist/ui/playground/client.js +18 -15
- package/dist/ui/playground/components/fields.js +35 -14
- package/dist/ui/playground/components/oauth-panel.js +71 -21
- package/dist/ui/playground/components/request-panel.js +79 -93
- package/dist/utils/create-page.js +2 -2
- package/dist/utils/get-example-requests.js +1 -1
- package/dist/utils/pages/to-text.js +1 -1
- package/dist/utils/use-server.d.ts +3 -3
- package/dist/utils/use-server.js +2 -2
- package/package.json +3 -3
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("!collapsed !isDefined !readOnly !renderBodyField !required !supported *:data-[collapsible=true]:order-last *:flex-1 *:justify-center *:min-w-0 --- --accordion-panel-height --active-tab-height --active-tab-left --active-tab-top --active-tab-width --anchor-width --available-height --collapsible-panel-height --fd-docs-row-1 --fd-docs-row-3 --spacing --transform-origin -mode -ms-0.5 -my-1 -translate-x-1/2 -translate-y-1/2 -z-1 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @deprecated @fuma-translate/react @fumadocs/json-schema @fumari/stf @max-sm:bg-fd-secondary/50 @max-sm:border @max-sm:empty:w-2 @max-sm:mx-4 @max-sm:overflow-hidden @max-sm:pb-1.5 @max-sm:pb-3 @max-sm:pe-2 @max-sm:rounded-lg @max-xl:basis-full @max-xl:border-t @max-xl:flex-1 @max-xl:ps-1.5 @md:block @md:grid-cols-2 @param @private @scalar/api-client-react @see @sm:-me-2 @sm:-me-2.5 @sm:border-s @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)] @sm:min-h-10 @sm:pe-7.5 @sm:pe-8 @typescript-eslint/no-explicit-any @xl:w-40 [&[hidden]:not([hidden='until-found'])]:hidden [&_*]:inline [&_a]:underline [&_code]:font-mono [&_svg]:size-3 [&_svg]:size-3.5 [--fd-docs-row-1:0px] [--fd-docs-row-3:0px] [grid-area:1/1] [scrollbar-width:none] a above absolute accept access access_token accordion actions active:scale-[0.97] actual adapter adapters added additional additionalProperties after again against alias align all allOf allow allowJson already alt among an anchor anchorSegments and animate-spin animates any anyFields anyOf anyway apiExample apiKey apiPlayground appearance-none application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml applies apply are aria-checked aria-current aria-expanded aria-expanded:decoration-solid aria-expanded:text-fd-accent-foreground aria-hidden aria-label aria-live aria-pressed aria-pressed:bg-fd-background aria-pressed:ring-1 aria-pressed:ring-fd-border aria-pressed:shadow-sm aria-pressed:text-fd-foreground arkdown array arrow as async at audience auth authCodeQuery authNode authSchemes authorization authorizationCode authorizationUrl authorization_code authorization_url authorize authorizes auto-cols-[minmax(0,max-content)] autoComplete available avoid await back backdrop-blur-[1px] backdrop-blur-sm backdrop-blur-xs background badgeVariants bar base baseDir basic basis-full be before behavior below between bg-amber-500 bg-amber-500/10 bg-black/30 bg-black/40 bg-blue-500 bg-current/10 bg-fd-background bg-fd-background/50 bg-fd-card bg-fd-card/70 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-primary/10 bg-fd-secondary bg-green-500 bg-linear-to-b bg-linear-to-t bg-red-500 bg-transparent binary block blocks blue body bodyMediaType bodyNode bodyUrlRef boolean border border-0 border-b border-current border-dashed border-fd-muted-foreground/50 border-fd-primary border-fd-primary/20 border-s border-t bottom bottom-0 box box-content breadcrumbs break-all built-in bundled but button buttonVariants by bytes cache cached cachedDocFiles callbacks callbacksNode can candidates cannot card case catch cell center ch change changes charset check checkbox checked chevron chevronClassName children class class-variance-authority className cleanup clearResponse click client clientAuth clientCredentials clientId clientSecret clientWidth client_auth client_credentials client_error client_id client_secret cloned closeDelay closest cn code codeProps codeUsages codeblock col-span-2 col-span-full collapse collapses collapsible color compiler components compute configuration const constraints container content contentTypes control cookie cookies copy copying core count createContext createOAuthHandler createOpenAPIPageBase createProxy credentials cross-origin crumbClassName crumbs css csv ctx current currentValue cursor-pointer cursor-text custom customise customization cva dark dark:aria-pressed:bg-fd-accent dark:bg-fd-accent dark:text-amber-400 dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-active:text-fd-foreground data-closed:animate-fd-dialog-out data-closed:animate-fd-fade-out data-collapsible data-ending-style:duration-150 data-ending-style:h-0 data-ending-style:opacity-0 data-ending-style:scale-95 data-ending-style:scale-[0.97] data-ending-style:scale-[0.98] data-highlighted:bg-fd-accent data-highlighted:text-fd-accent-foreground data-open:animate-fd-dialog-in data-open:animate-fd-fade-in data-placeholder:text-fd-muted-foreground data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground data-popup-open:text-fd-foreground data-starting-style:h-0 data-starting-style:opacity-0 data-starting-style:scale-95 data-starting-style:scale-[0.98] dataEngine decimal declare decode decoration-dotted default defaultMdxComponents defaultShikiFactory defaultShikiOptions defaultValue defaultValues defaults define definitions delay delay-150 deprecated depth dereference dereferenced described describes description descriptionNode descriptions development deviceAuthorization dialog didn direction directories disable disableCache disabled disabled:cursor-not-allowed disabled:opacity-50 disabled:opacity-80 display displayNames disposition div do doc docCache docFilesCache docRoot docs document documented documents does doesn domain don download downloaded drives drop duplicated duration duration-150 duration-200 duration-250 during dynamic dynamicSource e each eading ease-[cubic-bezier(0.16,1,0.3,1)] ease-[cubic-bezier(0.22,1,0.36,1)] ease-out edge edited editor edits element elements else empty empty:hidden enabled encode encodeRequestData encoded end end-2 endpoint enforce engine entries entry enum err error eslint-disable eslint-disable-next-line even example examples exclusiveMax exclusiveMin expand export exported expressions extended extends fades fallback false fast-content-type-parse fd-page-tree-item-name fd-scroll-container fetch fetchOptions fetcher field field-sizing-content fieldData fieldLabelVariants fieldName fields file fileName filePath files fill-current filling fills filter filterable first first:border-t-0 first:mt-0 fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flow-root flowInfo flowReturned flows flushSync focus-visible:bg-fd-accent focus-visible:bg-fd-accent/40 focus-visible:bg-fd-primary/15 focus-visible:bg-fd-secondary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-2 focus-visible:ring-fd-primary/30 focus-visible:ring-fd-ring focus-visible:ring-fd-ring/50 focus-visible:ring-fd-ring/60 focus-visible:ring-inset focus-within:ring-1 focus-within:ring-fd-ring focus:outline-none focus:ring focus:ring-0 focus:ring-fd-ring folder folderStyle follow font-light font-medium font-mono font-normal font-sans font-semibold for form form-encoded format forward fragment from from-fd-popover fs full fumadocs-core/source fumadocs-core/toc fumadocs-openapi-oauth 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-x-2 gap-x-3 gap-x-6 gap-y-1 gap-y-4 generate generateDefault generateSchemaUI generated get getLink getOpenAPIPageProps getPreferredType getSchema getSchemas getWatchPaths ghost github-dark github-light given go goes going grant_type gray green grid grid-cols-1 grid-cols-[auto_minmax(0,1fr)] grid-cols-[auto_minmax(0,1fr)_auto] grid-cols-[minmax(0,2fr)_minmax(0,3fr)] grid-flow-col group group-data-[panel-open]/accordion:rotate-90 group-data-popup-open:rotate-180 group-hover/nav:translate-x-0.5 group-hover/property:opacity-100 group-hover:translate-x-0.5 group-hover:translate-x-px group/accordion group/nav group/property group/row groupId h-(--accordion-panel-height) h-(--active-tab-height) h-(--collapsible-panel-height) h-10 h-12 h-5 h-6 h-7 h-8 h-9 h-[240px] h-auto h-full h-px h1 has has-focus-visible:bg-fd-secondary has-focus-visible:ring-1 has-focus-visible:ring-fd-ring/60 has-focus-visible:ring-inset hasSecret hash hast-util-to-jsx-runtime have headNode header headerRef headers heading headingLevel headless here hidden hiddenKeys hiddenProperties highlighted highlighter hint holding holds hook hover hover:bg-fd-accent hover:bg-fd-accent/40 hover:bg-fd-primary/15 hover:bg-transparent hover:text-fd-accent-foreground hover:text-fd-foreground how href html htmlFor http hydration i icon icon-sm icon-xs iconButtonClassName id idx if img implicit import imports in including index indicator info infoTags init initAuth initial inline inline-flex input inputMode inputs inset-0 inset-x-0 inside installed instanceof instead integer interface internal into invalid invisible is isDefined isDynamic isExpanded isHighlighted isLazy isLoading isMac isNumber isRequired isSending issues it item itemSchema items items-baseline items-center items-start items-stretch its itself js json json-schema-typed justify-between justify-center justify-end kB keep keeping keeps kept key keyed keyof keys kind label labelClassName labelled lang larger last last:border-b-0 last:shrink-0 layout layouts lazy leading-5 leading-none leading-relaxed leave leaving left left-0 left-1/2 length let light like line-through link links list listed listen listener listeners load loadDocument loaderPlugin loading localStorage location long longer lucide-react map mapValues margin margins marked match matching max max-age max-h-(--available-height) max-h-[min(18rem,30vh)] max-h-none max-md:hidden max-w-1/2 max-w-40 max-w-60 max-w-64 max-w-72 max-w-[calc(100vw-2rem)] max-w-full max-w-lg may mb-2 mb-3 md md:border-s md:grid-cols-[minmax(0,11fr)_minmax(0,9fr)] md:hidden mdxComponents me-1 me-auto measure measured media mediaAdapters mediaType member members menu menuItems merge message meta metaData metaKey method methods milliseconds mime min min-h-0 min-h-10 min-h-11 min-h-60 min-h-9 min-h-full min-w-0 min-w-16 min-w-40 min-w-[calc(var(--anchor-width)+--spacing(2))] mode motion motion-reduce:transition-none motion-reduce:transition-opacity motion-safe:-translate-x-6 motion-safe:duration-300 motion-safe:ease-[cubic-bezier(0.16,1,0.3,1)] motion-safe:starting:-translate-x-6 motion-safe:starting:-translate-y-4 motion-safe:starting:opacity-0 motion-safe:starting:scale-0 motion-safe:starting:translate-x-6 motion-safe:starting:translate-y-1 motion-safe:starting:translate-y-4 motion-safe:transition-[opacity,translate] motion-safe:transition-opacity motion-safe:transition-transform motionClassNames mounted ms ms-1 ms-1.5 ms-auto mt-0! mt-0.5 mt-1 mt-1.5 mt-10 mt-2 mt-2.5 multipart/form-data multiple must mx-1 mx-3 mx-px my-0 my-0! my-1 my-3 name name! named names namespace narrow nav navigator nearest needs nested never new next next/previous no no-cache noValidate node node:fs node:path noop normalizes not not-prose note null number oauth oauth2 oauthRedirectUrl object objectSet objects observer obtain of off omit on onAppend onAuthorized onBack onChange onCheckedChange onClick onCopy onKeyDown onLink onNavigate onOAuth onOpenChange onRemove onReset onRoot onSelect onSubmit onToken onValueChange one oneOf ones only opacity-0 opacity-80 open openApiData openIdConnect openOnHover openapi openapiMeta opened opening opens operation options or orange order-last origin origin-(--transform-origin) other otherwise out outline outline-none output over overflow-auto overflow-clip overflow-hidden overflow-x-auto overflow-y-auto overview own p-0 p-0.5 p-1 p-1.5 p-2 p-2.5 p-3 p-4 p-5 p-6 packages padding page pageData pages panel panelCodeBlock panelKey panels param parameter parameterLabel parameterNode parameters params parent parentIndex parents parsed parts party pass password path pathItem pathnameFromRequest pattern patternProperties payload pb-1 pb-2 pb-3 pe-1 pe-1.5 pe-2 pe-3 pe-4 peer-disabled:cursor-not-allowed peer-disabled:opacity-70 pending pendingFlowKey persisted picked pill placed placeholder placeholder:text-fd-muted-foreground placeholder:text-fd-muted-foreground/70 placeholder:text-fd-primary/50 playground playgrounds please plugins pointer-coarse:opacity-100 polite popup position pre preferred prefers preloadOpenAPIPage preloaded prev preview previous primary primitive processor prop properties property props prose prose-no-margin prose-sm proxy proxyForwardCookie proxyUrl ps-1 ps-1.5 ps-3 ps-3.5 ps-4 ps-6 pt-1.5 pt-2 pt-2.5 px-1 px-1.5 px-2 px-2.5 px-3 px-4 py-0 py-0.5 py-1 py-1.5 py-2 py-2.5 py-3 py-6 query quiet random range raw react react-dom react-hooks/exhaustive-deps react/jsx-runtime read read-only readOnly readonly record red redirect redirectUrl redirect_uri redirected redirects ref reference refs regenerated rehype-react relative relativePath remark remark-rehype remarkGfm remarkRehype remounted removable removal remove removeItem removed removing render renderBodyField renderCodeblock renderMarkdown renderParameterField rendered renderers renders replace replaces represents request request-body requestBody requestData requestInit requestTimeout requestUrl requested requests required requirement requirements res reserved reset resize-none resized resolve resolveMediaAdapter resolveUrl resolved resolvedInput resolvedTheme response response-body responseNode responseTabs response_type responses rest restored result return returned returning returns revoked right ring-1 ring-fd-border role room root rootId rotate-90 rounded rounded-[5px] rounded-full rounded-lg rounded-md rounded-none rounded-sm rounded-xl route row row-span-2 rowButtonClassName rows runtime s safeParse same satisfies scalar scan schema schemaId schemaKeys schemaPropKeys schemaUI schemas scheme schemeId schemes scope scopeOptions scopes screen screens scroll scroll-m-20 scroll-mt-[calc(var(--fd-docs-row-3,0px)+1rem)] scrollArrowClassName scrollMarginClassName search secondary seconds secret section sectionIcons sectionNames sections security see segments segs select select-none selected selectedType selector selectors selects self-center send sends separator server server-to-server serverSchema serverUrl services sessionStorage set setClientAuth setCode setCollapsed setDraft setError setFilter setInfo setMode setMotion setName setNextName setOAuth setOpen setOrigin setResponse setScopes setSelected setSending setServerVariables setShow setStack setStore setType setValue setView shadow-lg shadow-md shadow-none shadow-sm share shared shared-api/auto-anchor shiki shikiOptions shorten show showDescription showExample showResponseSchema showSelect showTitle shown shrink shrink-0 sibling siblings side sideOffset signal single size size-2 size-3 size-3.5 size-4 size-5 skipNonRequired skipReadOnly slashes slides sliding slot slotClassName slotType slots sm sm:-translate-x-1/2 sm:-translate-y-1/2 sm:border sm:flex-row sm:gap-2 sm:h-[min(52rem,calc(100dvh-3rem))] sm:inline sm:inset-auto sm:justify-end sm:left-1/2 sm:max-h-[min(52rem,calc(100dvh-3rem))] sm:mb-4 sm:mx-4 sm:ps-5 sm:px-4 sm:rounded-2xl sm:shadow-2xl sm:text-start sm:top-1/2 sm:w-[min(64rem,calc(100vw-3rem))] sm:w-[min(80rem,calc(100vw-3rem))] smaller smooth so some something space spellCheck sr-only src stable stack stacked start started starting starting:opacity-0 starts state staticSource status statusInfo stays step stf sticky still stops storageKey store stored string stringify stringifyFieldKey structuredData style styles submit subscribe such supported svg switch switches sync syncExample synced t tPlayground tab tables tabs tabular-nums tagClassName takes target tell text text-4xl text-[0.8125rem] text-amber-600 text-blue-600 text-center text-end text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/60 text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-primary-foreground/60 text-fd-secondary-foreground text-green-600 text-lg text-nowrap text-orange-600 text-red-400 text-red-400/80 text-red-600 text-sm text-start text-xs text-yellow-600 text/css text/csv text/html text/plain texts than that the their them themes then they this through throw timeout timer timerRef tips title to to-transparent toJsxRuntime toStaticData toc toggle toggled token tokenInfo tokenUrl token_type token_url tokens toolbar top top-(--active-tab-top) top-0 top-1/2 top-2 total tracking-tight transform transformAuthInputs transformPageTree transition-[background-color,scale] transition-[height,opacity] transition-[height] transition-[opacity,scale] transition-[translate,width] transition-colors transition-opacity transition-shadow transition-transform transitionClassName translate-x-(--active-tab-left) translations tree true truncate try ts type typeClassName typeof types unchanged undefined under underline underline-offset-4 unexpected union unionField unions unique unit unknown unlisted unset up update updateInfo updated updating url usageTabs usages use useAnchorId useAnchorLink useApiClient useComponents useCopyButton useFieldValue useListener useMemo useNamespace useObject useOnChange useOpenAPI useOperation usePlaygroundAuth useQuery useRef useRenderContext useResolvedSchema useResponseExamples useServer useState useStatusInfo useStf useSyncExternalStore useTheme useTranslations useTypeScriptDefinitions used username users using v value valueSchema values variable variables variant variants via view viewportProps virtual void w-(--active-tab-width) w-0 w-7 w-72 w-[min(26rem,calc(100vw-2rem))] w-auto w-fit w-full w-max warn we webhook webhooks when where while whitespace-pre width widths will window with without won would wrap-anywhere wrap-break-word wrapping write writeOnly x-exclusiveCodeSample x-playground-lazy xml yellow you your z-0 z-10 z-50");
|
|
1
|
+
@source inline("!collapsed !isDefined !readOnly !renderBodyField !required !supported *:data-[collapsible=true]:order-last *:flex-1 *:justify-center *:min-w-0 --- --accordion-panel-height --active-tab-height --active-tab-left --active-tab-top --active-tab-width --anchor-width --available-height --collapsible-panel-height --fd-docs-row-1 --fd-docs-row-3 --spacing --transform-origin -mode -ms-0.5 -my-1 -translate-x-1/2 -translate-y-1/2 -z-1 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @deprecated @fuma-translate/react @fumadocs/json-schema @fumari/stf @max-sm:bg-fd-secondary/50 @max-sm:border @max-sm:empty:w-2 @max-sm:mx-4 @max-sm:overflow-hidden @max-sm:pb-1.5 @max-sm:pb-3 @max-sm:pe-2 @max-sm:rounded-lg @max-xl:basis-full @max-xl:border-t @max-xl:flex-1 @max-xl:ps-1.5 @md:block @md:grid-cols-2 @param @private @returns @scalar/api-client-react @see @sm:-me-2 @sm:-me-2.5 @sm:border-s @sm:grid-cols-[minmax(9rem,1fr)_minmax(0,2fr)] @sm:min-h-10 @sm:pe-7.5 @sm:pe-8 @typescript-eslint/no-explicit-any @xl:w-40 [&[hidden]:not([hidden='until-found'])]:hidden [&_*]:inline [&_a]:underline [&_code]:font-mono [&_svg]:size-3 [&_svg]:size-3.5 [--fd-docs-row-1:0px] [--fd-docs-row-3:0px] [grid-area:1/1] [scrollbar-width:none] a above absolute accept access access_token accordion actions active:scale-[0.97] actual adapter adapters add added additional additionalProperties after again against alias align all allOf allow allowJson allowed already alt among an anchor anchorSegments and animate-spin animates any anyFields anyOf anyway apiExample apiKey apiPlayground appearance-none application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml applies apply are aria-checked aria-current aria-expanded aria-expanded:decoration-solid aria-expanded:text-fd-accent-foreground aria-hidden aria-label aria-live aria-pressed aria-pressed:bg-fd-background aria-pressed:ring-1 aria-pressed:ring-fd-border aria-pressed:shadow-sm aria-pressed:text-fd-foreground arkdown array arrow as async at audience auth authNode authProviders authSchemes authorization authorizationCode authorizationUrl authorization_code authorization_url authorize authorized authorizes auto-cols-[minmax(0,max-content)] autoComplete available avoid await back backdrop-blur-[1px] backdrop-blur-sm backdrop-blur-xs background badgeVariants bar base baseDir basic basis-full be before behavior below between bg-amber-500 bg-amber-500/10 bg-black/30 bg-black/40 bg-blue-500 bg-current/10 bg-fd-background bg-fd-background/50 bg-fd-card bg-fd-card/70 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-primary/10 bg-fd-secondary bg-green-500 bg-linear-to-b bg-linear-to-t bg-red-500 bg-transparent binary block blocks blue body bodyMediaType bodyNode bodyUrlRef boolean border border-0 border-b border-current border-dashed border-fd-muted-foreground/50 border-fd-primary border-fd-primary/20 border-s border-t bottom bottom-0 box box-content breadcrumbs break-all built-in builtinProviders bundled but button buttonVariants by bytes cache cached cachedDocFiles callbacks callbacksNode can candidates cannot card case catch cell center ch change changes charset check checkbox checked chevron chevronClassName children class class-variance-authority className cleanup clearResponse click client clientAuth clientCredentials clientId clientSecret clientWidth client_auth client_credentials client_error client_id client_secret cloned close closeDelay closest cn code codeProps codeUsages codeblock col-span-2 col-span-full collapse collapses collapsible color come compiler component components compute configuration const constraints container content contentTypes contents control cookie cookies copy copyable copying core count createContext createOAuthHandler createOpenAPIPageBase createProxy credentials cross-origin crumbClassName crumbs css csv ctx current currentValue cursor-pointer cursor-text custom customise customization cva dark dark:aria-pressed:bg-fd-accent dark:bg-fd-accent dark:text-amber-400 dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-active:text-fd-foreground data-closed:animate-fd-dialog-out data-closed:animate-fd-fade-out data-collapsible data-ending-style:duration-150 data-ending-style:h-0 data-ending-style:opacity-0 data-ending-style:scale-95 data-ending-style:scale-[0.97] data-ending-style:scale-[0.98] data-highlighted:bg-fd-accent data-highlighted:text-fd-accent-foreground data-open:animate-fd-dialog-in data-open:animate-fd-fade-in data-placeholder:text-fd-muted-foreground data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground data-popup-open:text-fd-foreground data-starting-style:h-0 data-starting-style:opacity-0 data-starting-style:scale-95 data-starting-style:scale-[0.98] dataEngine decimal declare decode decoration-dotted default defaultMdxComponents defaultShikiFactory defaultShikiOptions defaultValue defaultValues defaults define definitions delay delay-150 delete deprecated depth dereference dereferenced described describes description descriptionNode descriptions development deviceAuthorization dialog didn direction directories disable disableCache disabled disabled:cursor-not-allowed disabled:opacity-50 disabled:opacity-80 display displayNames disposition div do doc docCache docFilesCache docRoot docs document documented documents does doesn domain don download downloaded drives drop duplicated duration duration-150 duration-200 duration-250 during dynamic dynamicSource e each eading ease-[cubic-bezier(0.16,1,0.3,1)] ease-[cubic-bezier(0.22,1,0.36,1)] ease-out edge edited editing editor edits element elements else emit empty empty:hidden enabled encode encodeRequestData encoded end end-2 endpoint enforce engine entries entry enum err error eslint-disable eslint-disable-next-line even example examples exclusiveMax exclusiveMin expand export exported expressions extended extends fades fallback false fast-content-type-parse fd-page-tree-item-name fd-scroll-container fetch fetchOptions fetcher field field-sizing-content fieldData fieldLabelVariants fieldName fields file fileName filePath files fill-current filling fills filter filterable finishes first first:border-t-0 first:mt-0 fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flow-root flowInfo flowReturned flows flushSync focus-visible:bg-fd-accent focus-visible:bg-fd-accent/40 focus-visible:bg-fd-primary/15 focus-visible:bg-fd-secondary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-2 focus-visible:ring-fd-primary/30 focus-visible:ring-fd-ring focus-visible:ring-fd-ring/50 focus-visible:ring-fd-ring/60 focus-visible:ring-inset focus-within:ring-1 focus-within:ring-fd-ring focus:outline-none focus:ring focus:ring-0 focus:ring-fd-ring folder folderStyle follow font-light font-medium font-mono font-normal font-sans font-semibold for form form-encoded format forward fragment from from-fd-popover fs full fumadocs-core/source fumadocs-core/toc fumadocs-openapi-flow fumadocs-openapi-oauth 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-x-2 gap-x-3 gap-x-6 gap-y-1 gap-y-4 generate generateDefault generateSchemaUI generated get getLink getOpenAPIPageProps getPreferredType getSchema getSchemas getWatchPaths gets ghost github-dark github-light given go goes going grant_type gray green grid grid-cols-1 grid-cols-[auto_minmax(0,1fr)] grid-cols-[auto_minmax(0,1fr)_auto] grid-cols-[minmax(0,2fr)_minmax(0,3fr)] grid-flow-col group group-data-[panel-open]/accordion:rotate-90 group-data-popup-open:rotate-180 group-hover/nav:translate-x-0.5 group-hover/property:opacity-100 group-hover:translate-x-0.5 group-hover:translate-x-px group/accordion group/nav group/property group/row groupId h-(--accordion-panel-height) h-(--active-tab-height) h-(--collapsible-panel-height) h-10 h-12 h-5 h-6 h-7 h-8 h-9 h-[240px] h-auto h-full h-px h1 handle handles has has-focus-visible:bg-fd-secondary has-focus-visible:ring-1 has-focus-visible:ring-fd-ring/60 has-focus-visible:ring-inset hasSecret hash hast-util-to-jsx-runtime have headNode header headerRef headers heading headingLevel headless here hidden hiddenKeys hiddenProperties highlighted highlighter hint holding holds hook hover hover:bg-fd-accent hover:bg-fd-accent/40 hover:bg-fd-primary/15 hover:bg-transparent hover:text-fd-accent-foreground hover:text-fd-foreground how href html htmlFor http hydration i icon icon-sm icon-xs iconButtonClassName id idx if img implicit import imports in including index indicator info infoTags init initAuth initial inline inline-flex input inputMode inputs inset-0 inset-x-0 inside installed instanceof instead integer interface internal into invalid invisible is isDefined isDynamic isExpanded isHighlighted isLazy isLoading isMac isNumber isRequired isSending isn issues it item itemSchema items items-baseline items-center items-start items-stretch its itself js json json-schema-typed justify-between justify-center justify-end kB keep keeping keeps kept key keyed keyof keys kind label labelClassName labelled lang larger last last:border-b-0 last:shrink-0 layout layouts lazy leading-5 leading-none leading-relaxed leave leaving left left-0 left-1/2 length let light like line-through link links list listed listen listener listeners loadDocument loaderPlugin loading loads localStorage location long longer lucide-react map mapValues margin margins marked match matching max max-age max-h-(--available-height) max-h-[min(18rem,30vh)] max-h-none max-md:hidden max-w-1/2 max-w-40 max-w-60 max-w-64 max-w-72 max-w-[calc(100vw-2rem)] max-w-full max-w-lg may mb-2 mb-3 md md:border-s md:grid-cols-[minmax(0,11fr)_minmax(0,9fr)] md:hidden mdxComponents me-1 me-auto measure measured media mediaAdapters mediaType member members menu menuItems merge message meta metaData metaKey method methods milliseconds mime min min-h-0 min-h-10 min-h-11 min-h-60 min-h-9 min-h-full min-w-0 min-w-16 min-w-40 min-w-[calc(var(--anchor-width)+--spacing(2))] mode motion motion-reduce:transition-none motion-reduce:transition-opacity motion-safe:-translate-x-6 motion-safe:duration-300 motion-safe:ease-[cubic-bezier(0.16,1,0.3,1)] motion-safe:starting:-translate-x-6 motion-safe:starting:-translate-y-4 motion-safe:starting:opacity-0 motion-safe:starting:scale-0 motion-safe:starting:translate-x-6 motion-safe:starting:translate-y-1 motion-safe:starting:translate-y-4 motion-safe:transition-[opacity,translate] motion-safe:transition-opacity motion-safe:transition-transform motionClassNames mounted ms ms-1 ms-1.5 ms-auto mt-0! mt-0.5 mt-1 mt-1.5 mt-10 mt-2 mt-2.5 multipart/form-data multiple must mx-1 mx-3 mx-px my-0 my-0! my-1 my-3 name name! named names namespace narrow nav navigator nearest needs nested never new next next/previous no no-cache noValidate node node:fs node:path noop normalizes not not-prose note null number oauth2 oauthOrigin oauthPanelProvider oauthRedirectUrl object objectGet objects observer obtain of off omit omitted on onAppend onAuthorize onBack onChange onCheckedChange onClick onCopy onKeyDown onLink onMount onNavigate onOpenChange onRemove onReset onReturn onRoot onSelect onSubmit onToken onValueChange one oneOf ones only opacity-0 opacity-80 open openApiData openIdConnect openOnHover openapi openapiMeta opened opening opens operation options or orange order-last origin origin-(--transform-origin) other otherwise out outline outline-none output outside over overflow-auto overflow-clip overflow-hidden overflow-x-auto overflow-y-auto overview own p-0 p-0.5 p-1 p-1.5 p-2 p-2.5 p-3 p-4 p-5 p-6 packages padding page pageData pages panel panelCodeBlock panelKey panels param parameter parameterLabel parameterNode parameters params parent parentIndex parents parsed parts party pass password path pathItem pathnameFromRequest pattern patternProperties payload pb-1 pb-2 pb-3 pe-1 pe-1.5 pe-2 pe-3 pe-4 peer-disabled:cursor-not-allowed peer-disabled:opacity-70 pending pendingFlowKey pendingOAuthKey persisted pill placed placeholder placeholder:text-fd-muted-foreground placeholder:text-fd-muted-foreground/70 placeholder:text-fd-primary/50 playground playgrounds please plugins pointer-coarse:opacity-100 polite popup pre preferred prefers prefixed preloadOpenAPIPage preloaded prev preventDefault preview previous primary primitive processor prop properties property props prose prose-no-margin prose-sm provider providers proxy proxyForwardCookie proxyUrl ps-1 ps-1.5 ps-3 ps-3.5 ps-4 ps-6 pt-1.5 pt-2 pt-2.5 px-1 px-1.5 px-2 px-2.5 px-3 px-4 py-0 py-0.5 py-1 py-1.5 py-2 py-2.5 py-3 py-6 query quiet random range raw react react-dom react-hooks/exhaustive-deps react/jsx-runtime read read-only readOnly readonly record red redirect redirectUrl redirect_uri redirected redirects ref reference refs regenerated rehype-react relative relativePath remark remark-rehype remarkGfm remarkRehype remounted removable removal remove removeItem removed removing render renderBodyField renderCodeblock renderMarkdown renderParameterField rendered renderers renders replace replaces represents request request-body requestBody requestData requestInit requestTimeout requestUrl requested requests required requirement requirements res reserved reset resize-none resized resolve resolveMediaAdapter resolveUrl resolved resolvedInput resolvedTheme response response-body responseNode responseTabs response_type responses rest restored result return returnQuery returned returnedScheme returning returns revoked right ring-1 ring-fd-border role room root rootId rotate-90 rounded rounded-[5px] rounded-full rounded-lg rounded-md rounded-none rounded-sm rounded-xl route row row-span-2 rowButtonClassName rows runtime s safeParse same satisfies scalar scan schema schemaId schemaKeys schemaPropKeys schemaUI schemas scheme schemeId schemes scope scopeOptions scopes screen screens scroll scroll-m-20 scroll-mt-[calc(var(--fd-docs-row-3,0px)+1rem)] scrollArrowClassName scrollMarginClassName search secondary seconds secret section sectionIcons sectionNames sections security see segments segs select select-none selected selectedType selector selectors selects self-center send sending sends separator server server-to-server serverSchema serverUrl services sessionStorage set setAuthorizing setClientAuth setCode setCollapsed setDraft setError setFilter setInfo setMode setMotion setName setNextName setOpen setOrigin setResponse setScopes setSelected setSending setServerVariables setShow setStack setStore setType setValue setView shadow-lg shadow-md shadow-none shadow-sm share shared shared-api/auto-anchor shiki shikiOptions shorten show showDescription showExample showResponseSchema showSelect showTitle shown shrink shrink-0 sibling siblings side sideOffset signal signing single size size-2 size-3 size-3.5 size-4 size-5 skipNonRequired skipReadOnly slashes slides sliding slot slotClassName slotType slots sm sm:-translate-x-1/2 sm:-translate-y-1/2 sm:border sm:flex-row sm:gap-2 sm:h-[min(52rem,calc(100dvh-3rem))] sm:inline sm:inset-auto sm:justify-end sm:left-1/2 sm:max-h-[min(52rem,calc(100dvh-3rem))] sm:mb-4 sm:mx-4 sm:ps-5 sm:px-4 sm:rounded-2xl sm:shadow-2xl sm:text-start sm:top-1/2 sm:w-[min(64rem,calc(100vw-3rem))] sm:w-[min(80rem,calc(100vw-3rem))] smaller smooth so some something space spellCheck sr-only src stable stack stacked start started starting starting:opacity-0 starts state staticSource status statusInfo stays step stf sticky stops storageKey store stored string stringSchema stringify stringifyFieldKey structuredData style styles submit subscribe subscribeNever such supported svg switch switches sync syncExample synced t tPlayground tab tables tabs tabular-nums tagClassName takes target tell text text-4xl text-[0.8125rem] text-amber-600 text-blue-600 text-center text-end text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/60 text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-primary-foreground/60 text-fd-secondary-foreground text-green-600 text-lg text-nowrap text-orange-600 text-red-400 text-red-400/80 text-red-600 text-sm text-start text-xs text-yellow-600 text/css text/csv text/html text/plain texts than that the their them themes then they this through throw timeout timer timerRef tips title to to-transparent toJsxRuntime toStaticData toc toggle toggled token tokenUrl token_type token_url tokens toolbar top top-(--active-tab-top) top-0 top-1/2 top-2 total tracking-tight transform transformPageTree transition-[background-color,scale] transition-[height,opacity] transition-[height] transition-[opacity,scale] transition-[translate,width] transition-colors transition-opacity transition-shadow transition-transform transitionClassName translate-x-(--active-tab-left) translations tree true truncate try ts type typeClassName typeof types unchanged undefined under underline underline-offset-4 unexpected union unionField unions unique unit unknown unlisted unset update updateInfo updated updating url usageTabs usages use useAnchorId useAnchorLink useApiClient useComponents useCopyButton useFieldValue useListener useMemo useNamespace useObject useOnChange useOpenAPI useOperation useQuery useRef useRenderContext useResolvedSchema useResponseExamples useServer useState useStatusInfo useStf useSyncExternalStore useTheme useTranslations useTypeScriptDefinitions used username users using v value valueSchema values variable variables variant variants via view viewportProps virtual void w-(--active-tab-width) w-0 w-7 w-72 w-[min(26rem,calc(100vw-2rem))] w-auto w-fit w-full w-max warn we webhook webhooks when where while whitespace-pre width widths will window with without won would wrap-anywhere wrap-break-word wrapping write writeOnly x-exclusiveCodeSample x-playground-lazy xml yellow your z-0 z-10 z-50");
|
|
@@ -3,6 +3,7 @@ export type Translations = {
|
|
|
3
3
|
"1 item(playground)": string;
|
|
4
4
|
"Accepted(playground status info)": string;
|
|
5
5
|
"Add Item(playground)": string;
|
|
6
|
+
"Add this to the allowed redirect URIs of your OAuth application.(OAuth dialog)": string;
|
|
6
7
|
"Add(playground)": string;
|
|
7
8
|
"Authenticate using username and password.(OAuth dialog)": string;
|
|
8
9
|
"Authenticate with 3rd party services(OAuth dialog)": string;
|
|
@@ -32,6 +33,8 @@ export type Translations = {
|
|
|
32
33
|
"Conflict(playground status info)": string;
|
|
33
34
|
"Cookie Parameters(operation page)": string;
|
|
34
35
|
"Cookies(playground)": string;
|
|
36
|
+
"Copied(playground)(aria-label)": string;
|
|
37
|
+
"Copy(playground)(aria-label)": string;
|
|
35
38
|
"Created(playground status info)": string;
|
|
36
39
|
"Default(operation page)": string;
|
|
37
40
|
"Default(schema UI)": string;
|
|
@@ -77,7 +80,6 @@ export type Translations = {
|
|
|
77
80
|
"Not Modified(playground status info)": string;
|
|
78
81
|
"Not set(playground)": string;
|
|
79
82
|
"OK(playground status info)": string;
|
|
80
|
-
"OpenID Connect is not supported at the moment, you can still set an access token here.(playground)": string;
|
|
81
83
|
"OpenID Connect(security scheme)": string;
|
|
82
84
|
"Path Parameters(operation page)": string;
|
|
83
85
|
"Path(playground)": string;
|
|
@@ -3,6 +3,7 @@ var keys_default = [
|
|
|
3
3
|
"1 item(playground)",
|
|
4
4
|
"Accepted(playground status info)",
|
|
5
5
|
"Add Item(playground)",
|
|
6
|
+
"Add this to the allowed redirect URIs of your OAuth application.(OAuth dialog)",
|
|
6
7
|
"Add(playground)",
|
|
7
8
|
"Authenticate using username and password.(OAuth dialog)",
|
|
8
9
|
"Authenticate with 3rd party services(OAuth dialog)",
|
|
@@ -32,6 +33,8 @@ var keys_default = [
|
|
|
32
33
|
"Conflict(playground status info)",
|
|
33
34
|
"Cookie Parameters(operation page)",
|
|
34
35
|
"Cookies(playground)",
|
|
36
|
+
"Copied(playground)(aria-label)",
|
|
37
|
+
"Copy(playground)(aria-label)",
|
|
35
38
|
"Created(playground status info)",
|
|
36
39
|
"Default(operation page)",
|
|
37
40
|
"Default(schema UI)",
|
|
@@ -77,7 +80,6 @@ var keys_default = [
|
|
|
77
80
|
"Not Modified(playground status info)",
|
|
78
81
|
"Not set(playground)",
|
|
79
82
|
"OK(playground status info)",
|
|
80
|
-
"OpenID Connect is not supported at the moment, you can still set an access token here.(playground)",
|
|
81
83
|
"OpenID Connect(security scheme)",
|
|
82
84
|
"Path Parameters(operation page)",
|
|
83
85
|
"Path(playground)",
|
package/dist/operation.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createCodeUsageGeneratorRegistry, pathnameFromRequest } from "./requests/generators/index.js";
|
|
3
|
-
import { joinURL } from "./packages/shared-api/dist/utils/url.js";
|
|
4
|
-
import { ServerProvider, useServer } from "./utils/use-server.js";
|
|
5
|
-
import { useOpenAPI } from "./utils/create-page.js";
|
|
6
3
|
import { idToTitle } from "./packages/shared-api/dist/utils/id-to-title.js";
|
|
7
|
-
import {
|
|
4
|
+
import { joinURL } from "./packages/shared-api/dist/utils/url.js";
|
|
8
5
|
import { encodeRequestData } from "./requests/media/encode.js";
|
|
6
|
+
import { getExampleValue, getPreferredType, methodKeys } from "./utils/schema.js";
|
|
9
7
|
import { getExampleRequests } from "./utils/get-example-requests.js";
|
|
8
|
+
import { ServerProvider, useServer } from "./utils/use-server.js";
|
|
9
|
+
import { useOpenAPI } from "./utils/create-page.js";
|
|
10
10
|
import { createContext, use, useMemo, useSyncExternalStore } from "react";
|
|
11
11
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
12
12
|
import { sample } from "@fumadocs/json-schema";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { RawRequestData } from "../requests/types.js";
|
|
1
2
|
import { OAuth2SecurityScheme, OperationObject, SecuritySchemeObject } from "../types.js";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
+
import { FC, ReactNode } from "react";
|
|
4
|
+
import { JsonSchema } from "@fumadocs/json-schema";
|
|
3
5
|
import { DataEngine, FieldKey } from "@fumari/stf";
|
|
4
6
|
//#region src/playground/auth.d.ts
|
|
5
7
|
export type OAuthFlowType = keyof NonNullable<OAuth2SecurityScheme['flows']>;
|
|
@@ -22,14 +24,25 @@ export interface OAuthFlowInput {
|
|
|
22
24
|
redirectUrl?: string;
|
|
23
25
|
/** where the flow started, like an operation, restored when it returns to the page */
|
|
24
26
|
origin?: string;
|
|
27
|
+
/**
|
|
28
|
+
* leave the page for `implicit` and `authorizationCode`, like the one of `useAuthRedirect()`, `finishOAuthFlow()` takes `data` when it returns.
|
|
29
|
+
*
|
|
30
|
+
* By default, `usePlaygroundAuth()` finishes them.
|
|
31
|
+
*/
|
|
32
|
+
redirect?: (url: URL, data: unknown) => void;
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
35
|
* Run an OAuth flow and resolve its token.
|
|
28
36
|
*
|
|
29
|
-
* `implicit` and `authorizationCode` leave the page instead
|
|
30
|
-
* in `usePlaygroundAuth().store`.
|
|
37
|
+
* `implicit` and `authorizationCode` leave the page instead, see `redirect`.
|
|
31
38
|
*/
|
|
32
|
-
export declare function requestOAuthToken(scheme: OAuth2SecurityScheme, type: OAuthFlowType, { schemeId, scopes, clientId, clientSecret, username, password, clientAuth, serverUrl, redirectUrl, origin }: OAuthFlowInput): Promise<string | undefined>;
|
|
39
|
+
export declare function requestOAuthToken(scheme: OAuth2SecurityScheme, type: OAuthFlowType, { schemeId, scopes, clientId, clientSecret, username, password, clientAuth, serverUrl, redirectUrl, origin, redirect }: OAuthFlowInput): Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Finish an `implicit` or `authorizationCode` flow of `requestOAuthToken()` from the URL it returned to.
|
|
42
|
+
*
|
|
43
|
+
* @returns the token, `undefined` when the URL isn't returning from it
|
|
44
|
+
*/
|
|
45
|
+
export declare function finishOAuthFlow(url: URL, data: unknown): Promise<string> | string | undefined;
|
|
33
46
|
/** scheme name -> token info */
|
|
34
47
|
type TokenStore = Record<string, TokenInfo | undefined>;
|
|
35
48
|
type TokenInfo = {
|
|
@@ -54,12 +67,52 @@ interface AuthContextType {
|
|
|
54
67
|
subscribe: (listener: TokenListener) => () => void;
|
|
55
68
|
}
|
|
56
69
|
export declare function usePlaygroundAuth(): AuthContextType;
|
|
70
|
+
/**
|
|
71
|
+
* Leave the page for a flow of field, like signing in, with the returned function.
|
|
72
|
+
*
|
|
73
|
+
* When the page loads again, the playground reopens, and `onReturn` gets the URL and `data` of flow.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useAuthRedirect(field: AuthField, onReturn?: (url: URL, data: unknown) => void): (url: string | URL, data?: unknown) => void;
|
|
57
76
|
export interface AuthRequirement {
|
|
58
77
|
/** id of the security scheme */
|
|
59
78
|
id: string;
|
|
60
79
|
scopes: string[];
|
|
61
80
|
scheme: SecuritySchemeObject;
|
|
62
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* How the playground handles a security scheme: its rows, and how its value authorizes requests.
|
|
84
|
+
*
|
|
85
|
+
* Omitted options come from the next provider of the scheme, and then the built-in one.
|
|
86
|
+
*/
|
|
87
|
+
export interface AuthProvider {
|
|
88
|
+
/** the ID of security schemes it handles, or a function. Every scheme when omitted */
|
|
89
|
+
on?: string | ((item: AuthRequirement) => boolean);
|
|
90
|
+
/** the rows of field */
|
|
91
|
+
render?: FC<AuthRenderProps>;
|
|
92
|
+
/** write the value into request data, for sending and code usages */
|
|
93
|
+
onRequest?: (data: RawRequestData, value: unknown, field: AuthField) => void;
|
|
94
|
+
}
|
|
95
|
+
export interface AuthRenderProps {
|
|
96
|
+
field: AuthField;
|
|
97
|
+
/** a row editing the value, or its property at `path` */
|
|
98
|
+
Value: FC<{
|
|
99
|
+
name: string;
|
|
100
|
+
type?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
schema?: Exclude<JsonSchema, boolean>;
|
|
103
|
+
path?: string;
|
|
104
|
+
}>;
|
|
105
|
+
/** a row opening `component` in a panel */
|
|
106
|
+
Panel: FC<{
|
|
107
|
+
title: ReactNode;
|
|
108
|
+
component: FC<AuthPanelProps>;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
export interface AuthPanelProps {
|
|
112
|
+
field: AuthField;
|
|
113
|
+
/** back to the request */
|
|
114
|
+
close: () => void;
|
|
115
|
+
}
|
|
63
116
|
export interface AuthField {
|
|
64
117
|
schemeId: string;
|
|
65
118
|
scheme: SecuritySchemeObject;
|
|
@@ -69,8 +122,7 @@ export interface AuthField {
|
|
|
69
122
|
/** `localStorage` key of its persisted value */
|
|
70
123
|
storageKey: string;
|
|
71
124
|
defaultValue: unknown;
|
|
72
|
-
|
|
73
|
-
mapOutput?: (value: unknown) => unknown;
|
|
125
|
+
provider: AuthProvider;
|
|
74
126
|
}
|
|
75
127
|
export interface AuthFields {
|
|
76
128
|
/** the security requirements of the operation, one of them authorizes the request */
|
|
@@ -88,11 +140,13 @@ export interface AuthFields {
|
|
|
88
140
|
export interface AuthFieldsOptions {
|
|
89
141
|
/** the operation to authorize, defaults to the security of the document */
|
|
90
142
|
operation?: OperationObject;
|
|
143
|
+
/** handle security schemes, before the built-in providers */
|
|
144
|
+
providers?: AuthProvider[];
|
|
91
145
|
/** customise the generated fields, like their default values */
|
|
92
146
|
transform?: (fields: AuthField[]) => AuthField[];
|
|
93
147
|
}
|
|
94
148
|
/**
|
|
95
149
|
* The auth fields of an API playground: the values it persists, and the request data they encode into.
|
|
96
150
|
*/
|
|
97
|
-
export declare function useAuthFields(engine: DataEngine, { operation, transform }?: AuthFieldsOptions): AuthFields;
|
|
151
|
+
export declare function useAuthFields(engine: DataEngine, { operation, providers, transform }?: AuthFieldsOptions): AuthFields;
|
|
98
152
|
//#endregion
|
package/dist/playground/auth.js
CHANGED
|
@@ -1,43 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery } from "../packages/shared-api/dist/utils/use-query.js";
|
|
3
|
+
import { useOperation } from "../operation.js";
|
|
3
4
|
import { useOpenAPI } from "../utils/create-page.js";
|
|
4
5
|
import { createContext, use, useCallback, useEffect, useEffectEvent, useMemo, useState } from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { useListener } from "@fumari/stf";
|
|
7
|
-
import { arrayStartsWith, objectGet
|
|
8
|
+
import { arrayStartsWith, objectGet } from "@fumari/stf/lib/utils";
|
|
8
9
|
//#region src/playground/auth.tsx
|
|
9
|
-
const
|
|
10
|
+
const pendingOAuthKey = "fumadocs-openapi-oauth";
|
|
11
|
+
const pendingFlowKey = "fumadocs-openapi-flow";
|
|
12
|
+
function readPendingFlow() {
|
|
13
|
+
const stored = sessionStorage.getItem(pendingFlowKey);
|
|
14
|
+
if (stored) return JSON.parse(stored);
|
|
15
|
+
}
|
|
16
|
+
function leavePage(url, redirectUrl, flow) {
|
|
17
|
+
if (flow) sessionStorage.setItem(pendingFlowKey, JSON.stringify(flow));
|
|
18
|
+
if (redirectUrl) document.cookie = `fumadocs-openapi-oauth=${encodeURIComponent(window.location.pathname)}; path=/`;
|
|
19
|
+
window.location.replace(url);
|
|
20
|
+
}
|
|
10
21
|
/**
|
|
11
22
|
* Run an OAuth flow and resolve its token.
|
|
12
23
|
*
|
|
13
|
-
* `implicit` and `authorizationCode` leave the page instead
|
|
14
|
-
* in `usePlaygroundAuth().store`.
|
|
24
|
+
* `implicit` and `authorizationCode` leave the page instead, see `redirect`.
|
|
15
25
|
*/
|
|
16
|
-
async function requestOAuthToken(scheme, type, { schemeId, scopes, clientId, clientSecret, username, password, clientAuth, serverUrl, redirectUrl, origin }) {
|
|
26
|
+
async function requestOAuthToken(scheme, type, { schemeId, scopes, clientId, clientSecret, username, password, clientAuth, serverUrl, redirectUrl, origin, redirect }) {
|
|
17
27
|
const flows = scheme.flows ?? {};
|
|
18
28
|
const scope = scopes.join(" ");
|
|
19
29
|
if (type === "implicit" || type === "authorizationCode") {
|
|
20
30
|
const flow = flows[type];
|
|
21
31
|
if (!flow) return;
|
|
22
|
-
const
|
|
32
|
+
const data = {
|
|
23
33
|
state: crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(4)).join(""),
|
|
24
|
-
scheme: schemeId,
|
|
25
34
|
client_id: clientId,
|
|
26
35
|
client_secret: clientSecret,
|
|
27
36
|
client_auth: clientAuth,
|
|
28
37
|
redirect_uri: new URL(redirectUrl ?? window.location.pathname, window.location.origin).href,
|
|
29
|
-
token_url: "tokenUrl" in flow ? new URL(flow.tokenUrl, serverUrl).href : void 0
|
|
30
|
-
origin
|
|
38
|
+
token_url: "tokenUrl" in flow ? new URL(flow.tokenUrl, serverUrl).href : void 0
|
|
31
39
|
};
|
|
32
|
-
sessionStorage.setItem(pendingFlowKey, JSON.stringify(pending));
|
|
33
|
-
if (redirectUrl) document.cookie = `fumadocs-openapi-oauth=${encodeURIComponent(window.location.pathname)}; path=/`;
|
|
34
40
|
const url = new URL(flow.authorizationUrl, serverUrl);
|
|
35
41
|
url.searchParams.set("response_type", type === "implicit" ? "token" : "code");
|
|
36
42
|
url.searchParams.set("client_id", clientId);
|
|
37
|
-
url.searchParams.set("redirect_uri",
|
|
43
|
+
url.searchParams.set("redirect_uri", data.redirect_uri);
|
|
38
44
|
url.searchParams.set("scope", scope);
|
|
39
|
-
url.searchParams.set("state",
|
|
40
|
-
|
|
45
|
+
url.searchParams.set("state", data.state);
|
|
46
|
+
if (redirect) redirect(url, data);
|
|
47
|
+
else {
|
|
48
|
+
const pending = {
|
|
49
|
+
...data,
|
|
50
|
+
scheme: schemeId,
|
|
51
|
+
origin
|
|
52
|
+
};
|
|
53
|
+
sessionStorage.setItem(pendingOAuthKey, JSON.stringify(pending));
|
|
54
|
+
leavePage(url, redirectUrl);
|
|
55
|
+
}
|
|
41
56
|
return;
|
|
42
57
|
}
|
|
43
58
|
if (type !== "password" && type !== "clientCredentials") return;
|
|
@@ -55,6 +70,26 @@ async function requestOAuthToken(scheme, type, { schemeId, scopes, clientId, cli
|
|
|
55
70
|
client_auth: clientAuth
|
|
56
71
|
});
|
|
57
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Finish an `implicit` or `authorizationCode` flow of `requestOAuthToken()` from the URL it returned to.
|
|
75
|
+
*
|
|
76
|
+
* @returns the token, `undefined` when the URL isn't returning from it
|
|
77
|
+
*/
|
|
78
|
+
function finishOAuthFlow(url, data) {
|
|
79
|
+
const flow = data;
|
|
80
|
+
const code = url.searchParams.get("code");
|
|
81
|
+
if (code && url.searchParams.get("state") === flow.state) {
|
|
82
|
+
const body = new URLSearchParams({
|
|
83
|
+
grant_type: "authorization_code",
|
|
84
|
+
code,
|
|
85
|
+
redirect_uri: flow.redirect_uri
|
|
86
|
+
});
|
|
87
|
+
return fetchToken(flow.token_url, body, flow);
|
|
88
|
+
}
|
|
89
|
+
const hash = new URLSearchParams(url.hash.slice(1));
|
|
90
|
+
const token = hash.get("access_token");
|
|
91
|
+
if (token && hash.get("state") === flow.state) return `${hash.get("token_type") ?? "Bearer"} ${token}`;
|
|
92
|
+
}
|
|
58
93
|
async function fetchToken(tokenUrl, body, { client_id, client_secret, client_auth }) {
|
|
59
94
|
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
|
60
95
|
if (client_auth === "header" && client_secret) headers.Authorization = `Basic ${btoa(`${encodeURIComponent(client_id)}:${encodeURIComponent(client_secret)}`)}`;
|
|
@@ -77,67 +112,65 @@ function usePlaygroundAuth() {
|
|
|
77
112
|
if (!ctx) throw new Error("Component must be used under <OpenAPIProvider />");
|
|
78
113
|
return ctx;
|
|
79
114
|
}
|
|
80
|
-
function
|
|
115
|
+
function PlaygroundAuthProvider({ children }) {
|
|
81
116
|
const [store, setStore] = useState({});
|
|
82
117
|
const [origin, setOrigin] = useState();
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
118
|
+
const { subscribe, emit } = useMemo(() => {
|
|
119
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
120
|
+
return {
|
|
121
|
+
subscribe(listener) {
|
|
122
|
+
listeners.add(listener);
|
|
123
|
+
return () => {
|
|
124
|
+
listeners.delete(listener);
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
emit(schemeId, token) {
|
|
128
|
+
for (const listener of listeners) listener(schemeId, token);
|
|
129
|
+
}
|
|
88
130
|
};
|
|
89
|
-
}, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const token = await fetchToken(flow.token_url, new URLSearchParams({
|
|
99
|
-
grant_type: "authorization_code",
|
|
100
|
-
code,
|
|
101
|
-
redirect_uri: flow.redirect_uri
|
|
102
|
-
}), flow);
|
|
103
|
-
save(flow.scheme, {
|
|
131
|
+
}, []);
|
|
132
|
+
const returnQuery = useQuery(async (flow, result) => {
|
|
133
|
+
setOrigin(flow.origin);
|
|
134
|
+
const token = await result;
|
|
135
|
+
const info = typeof result === "string" ? {
|
|
136
|
+
type: "implicit",
|
|
137
|
+
client_id: flow.client_id,
|
|
138
|
+
token
|
|
139
|
+
} : {
|
|
104
140
|
type: "authorization_code",
|
|
105
141
|
client_id: flow.client_id,
|
|
106
142
|
client_secret: flow.client_secret,
|
|
107
143
|
client_auth: flow.client_auth,
|
|
108
144
|
token
|
|
109
|
-
}
|
|
145
|
+
};
|
|
146
|
+
setStore((s) => ({
|
|
147
|
+
...s,
|
|
148
|
+
[flow.scheme]: info
|
|
149
|
+
}));
|
|
150
|
+
emit(flow.scheme, token);
|
|
110
151
|
});
|
|
111
|
-
|
|
112
|
-
const stored = sessionStorage.getItem(
|
|
152
|
+
const onMount = useEffectEvent(() => {
|
|
153
|
+
const stored = sessionStorage.getItem(pendingOAuthKey);
|
|
113
154
|
if (!stored) return;
|
|
114
155
|
const flow = JSON.parse(stored);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const token = hash.get("access_token");
|
|
119
|
-
if (code && query.get("state") === flow.state) authCodeQuery.start(code, flow);
|
|
120
|
-
else if (token && hash.get("state") === flow.state) save(flow.scheme, {
|
|
121
|
-
type: "implicit",
|
|
122
|
-
client_id: flow.client_id,
|
|
123
|
-
token: `${hash.get("token_type") ?? "Bearer"} ${token}`
|
|
124
|
-
});
|
|
125
|
-
else return;
|
|
126
|
-
setOrigin(flow.origin);
|
|
127
|
-
sessionStorage.removeItem(pendingFlowKey);
|
|
156
|
+
const result = finishOAuthFlow(new URL(window.location.href), flow);
|
|
157
|
+
if (result === void 0) return;
|
|
158
|
+
sessionStorage.removeItem(pendingOAuthKey);
|
|
128
159
|
window.history.replaceState(null, "", window.location.pathname);
|
|
129
|
-
|
|
160
|
+
returnQuery.start(flow, result);
|
|
161
|
+
});
|
|
162
|
+
useEffect(() => onMount(), []);
|
|
130
163
|
return /* @__PURE__ */ jsx(AuthContext, {
|
|
131
164
|
value: useMemo(() => ({
|
|
132
165
|
store,
|
|
133
|
-
isLoading:
|
|
134
|
-
error:
|
|
166
|
+
isLoading: returnQuery.isLoading,
|
|
167
|
+
error: returnQuery.error,
|
|
135
168
|
origin,
|
|
136
169
|
subscribe
|
|
137
170
|
}), [
|
|
138
171
|
store,
|
|
139
|
-
|
|
140
|
-
|
|
172
|
+
returnQuery.isLoading,
|
|
173
|
+
returnQuery.error,
|
|
141
174
|
origin,
|
|
142
175
|
subscribe
|
|
143
176
|
]),
|
|
@@ -145,9 +178,95 @@ function AuthProvider({ children }) {
|
|
|
145
178
|
});
|
|
146
179
|
}
|
|
147
180
|
/**
|
|
181
|
+
* Leave the page for a flow of field, like signing in, with the returned function.
|
|
182
|
+
*
|
|
183
|
+
* When the page loads again, the playground reopens, and `onReturn` gets the URL and `data` of flow.
|
|
184
|
+
*/
|
|
185
|
+
function useAuthRedirect(field, onReturn) {
|
|
186
|
+
const { oauthRedirectUrl } = useOpenAPI();
|
|
187
|
+
const { method, path } = useOperation();
|
|
188
|
+
const origin = `${method} ${path}`;
|
|
189
|
+
const onMount = useEffectEvent(() => {
|
|
190
|
+
if (!onReturn) return;
|
|
191
|
+
const flow = readPendingFlow();
|
|
192
|
+
if (flow?.scheme !== field.schemeId || flow.origin !== origin) return;
|
|
193
|
+
sessionStorage.removeItem(pendingFlowKey);
|
|
194
|
+
const url = new URL(window.location.href);
|
|
195
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
196
|
+
onReturn(url, flow.data);
|
|
197
|
+
});
|
|
198
|
+
useEffect(() => onMount(), []);
|
|
199
|
+
return (url, data) => leavePage(url, oauthRedirectUrl, {
|
|
200
|
+
scheme: field.schemeId,
|
|
201
|
+
origin,
|
|
202
|
+
data
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const builtinProviders = [
|
|
206
|
+
{
|
|
207
|
+
on: ({ scheme }) => scheme.type === "http" && scheme.scheme === "basic",
|
|
208
|
+
render: ({ field, Value }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Value, {
|
|
209
|
+
name: "username",
|
|
210
|
+
type: "basic",
|
|
211
|
+
description: field.scheme.description,
|
|
212
|
+
path: "username"
|
|
213
|
+
}), /* @__PURE__ */ jsx(Value, {
|
|
214
|
+
name: "password",
|
|
215
|
+
path: "password",
|
|
216
|
+
schema: {
|
|
217
|
+
type: "string",
|
|
218
|
+
format: "password"
|
|
219
|
+
}
|
|
220
|
+
})] }),
|
|
221
|
+
onRequest(data, value) {
|
|
222
|
+
const { username, password } = value;
|
|
223
|
+
data.header.Authorization = `Basic ${btoa(`${username}:${password}`)}`;
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
on: ({ scheme }) => scheme.type === "apiKey",
|
|
228
|
+
render: ({ field: { scheme }, Value }) => scheme.type === "apiKey" && /* @__PURE__ */ jsx(Value, {
|
|
229
|
+
name: scheme.name,
|
|
230
|
+
type: scheme.in,
|
|
231
|
+
description: scheme.description
|
|
232
|
+
}),
|
|
233
|
+
onRequest(data, value, { scheme }) {
|
|
234
|
+
if (scheme.type === "apiKey") data[scheme.in][scheme.name] = value;
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
render: ({ field, Value }) => /* @__PURE__ */ jsx(Value, {
|
|
239
|
+
name: "Authorization",
|
|
240
|
+
type: "header",
|
|
241
|
+
description: field.scheme.description
|
|
242
|
+
}),
|
|
243
|
+
onRequest(data, value) {
|
|
244
|
+
data.header.Authorization = value;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
function findProvider(providers = [], item) {
|
|
249
|
+
const match = ({ on }) => on === void 0 || (typeof on === "string" ? on === item.id : on(item));
|
|
250
|
+
let provider = builtinProviders.find(match);
|
|
251
|
+
for (let i = providers.length - 1; i >= 0; i--) if (match(providers[i])) provider = {
|
|
252
|
+
...provider,
|
|
253
|
+
...providers[i]
|
|
254
|
+
};
|
|
255
|
+
return provider;
|
|
256
|
+
}
|
|
257
|
+
function getDefaultValue(scheme) {
|
|
258
|
+
if (scheme.type === "apiKey") return "";
|
|
259
|
+
if (scheme.type !== "http" || !scheme.scheme) return "Bearer ";
|
|
260
|
+
if (scheme.scheme === "basic") return {
|
|
261
|
+
username: "",
|
|
262
|
+
password: ""
|
|
263
|
+
};
|
|
264
|
+
return `${scheme.scheme[0].toUpperCase()}${scheme.scheme.slice(1)} `;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
148
267
|
* The auth fields of an API playground: the values it persists, and the request data they encode into.
|
|
149
268
|
*/
|
|
150
|
-
function useAuthFields(engine, { operation, transform } = {}) {
|
|
269
|
+
function useAuthFields(engine, { operation, providers, transform } = {}) {
|
|
151
270
|
const { subscribe } = usePlaygroundAuth();
|
|
152
271
|
const { storageKeyPrefix, doc } = useOpenAPI();
|
|
153
272
|
const { dereferenced, resolve } = doc;
|
|
@@ -182,48 +301,27 @@ function useAuthFields(engine, { operation, transform } = {}) {
|
|
|
182
301
|
const requirement = selected === -1 ? null : requirements[selected];
|
|
183
302
|
const fields = useMemo(() => {
|
|
184
303
|
if (!requirement) return [];
|
|
185
|
-
const out = requirement.map((
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
fieldName: ["header", "Authorization"],
|
|
195
|
-
defaultValue: {
|
|
196
|
-
username: "",
|
|
197
|
-
password: ""
|
|
198
|
-
},
|
|
199
|
-
mapOutput(value) {
|
|
200
|
-
if (!value || typeof value !== "object") return value;
|
|
201
|
-
const { username = "", password = "" } = value;
|
|
202
|
-
return `Basic ${btoa(`${username}:${password}`)}`;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
if (scheme.type === "apiKey") return {
|
|
206
|
-
...shared,
|
|
207
|
-
fieldName: [scheme.in, scheme.name],
|
|
208
|
-
defaultValue: ""
|
|
209
|
-
};
|
|
210
|
-
return {
|
|
211
|
-
...shared,
|
|
212
|
-
fieldName: ["header", "Authorization"],
|
|
213
|
-
defaultValue: scheme.type === "http" || scheme.type === "oauth2" ? "Bearer " : ""
|
|
214
|
-
};
|
|
215
|
-
});
|
|
304
|
+
const out = requirement.map((item) => ({
|
|
305
|
+
schemeId: item.id,
|
|
306
|
+
scheme: item.scheme,
|
|
307
|
+
scopes: item.scopes,
|
|
308
|
+
fieldName: ["auth", item.id],
|
|
309
|
+
storageKey: `${storageKeyPrefix}auth-${item.id}`,
|
|
310
|
+
defaultValue: getDefaultValue(item.scheme),
|
|
311
|
+
provider: findProvider(providers, item)
|
|
312
|
+
}));
|
|
216
313
|
return transform ? transform(out) : out;
|
|
217
314
|
}, [
|
|
218
315
|
requirement,
|
|
219
316
|
storageKeyPrefix,
|
|
317
|
+
providers,
|
|
220
318
|
transform
|
|
221
319
|
]);
|
|
222
320
|
useListener({
|
|
223
321
|
stf: engine,
|
|
224
322
|
onUpdate(key) {
|
|
225
323
|
for (const field of fields) {
|
|
226
|
-
if (!arrayStartsWith(field.fieldName, key)) continue;
|
|
324
|
+
if (!arrayStartsWith(key, field.fieldName) && !arrayStartsWith(field.fieldName, key)) continue;
|
|
227
325
|
const value = engine.get(field.fieldName);
|
|
228
326
|
if (value != null) localStorage.setItem(field.storageKey, JSON.stringify(value));
|
|
229
327
|
}
|
|
@@ -249,10 +347,9 @@ function useAuthFields(engine, { operation, transform } = {}) {
|
|
|
249
347
|
fields,
|
|
250
348
|
mapValues: useCallback((values) => {
|
|
251
349
|
const cloned = structuredClone(values);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
350
|
+
const data = cloned;
|
|
351
|
+
for (const field of fields) field.provider.onRequest(data, objectGet(data, field.fieldName), field);
|
|
352
|
+
delete data.auth;
|
|
256
353
|
return cloned;
|
|
257
354
|
}, [fields]),
|
|
258
355
|
init: useCallback(() => {
|
|
@@ -274,4 +371,4 @@ function useAuthFields(engine, { operation, transform } = {}) {
|
|
|
274
371
|
};
|
|
275
372
|
}
|
|
276
373
|
//#endregion
|
|
277
|
-
export {
|
|
374
|
+
export { PlaygroundAuthProvider, finishOAuthFlow, readPendingFlow, requestOAuthToken, useAuthFields, useAuthRedirect, usePlaygroundAuth };
|