Download web/src/settings/KeyOpenApiRow.tsx from fsanyoto/loopable: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/fsanyoto/loopable/resolve/623acbc433f972703d46dcda190a3d39c4064fa7/web/src/settings/KeyOpenApiRow.tsx
- Command line
-
hf download hf://spaces/fsanyoto/loopable@623acbc433f972703d46dcda190a3d39c4064fa7/web/src/settings/KeyOpenApiRow.tsx
-
curl -L -o KeyOpenApiRow.tsx https://huggingface.co/spaces/fsanyoto/loopable/resolve/623acbc433f972703d46dcda190a3d39c4064fa7/web/src/settings/KeyOpenApiRow.tsx
1.1 kB
| import type { ReactNode } from "react"; | |
| export function openApiDocumentUrl(apiBase: string, origin: string): string { | |
| return new URL(`${apiBase.replace(/\/+$/, "")}/external/openapi.json`, origin).href; | |
| } | |
| export function openApiTypesCommand(documentUrl: string): string { | |
| return `curl -fsS -H "Authorization: Bearer $LOOPABLE_API_KEY" ${documentUrl} | npx openapi-typescript -o loopable.d.ts`; | |
| } | |
| type Props = { | |
| documentUrl: string; | |
| renderCode: (value: string, name: string, content?: ReactNode) => ReactNode; | |
| }; | |
| export function KeyOpenApiRow({ documentUrl, renderCode }: Props) { | |
| return ( | |
| <details className="external-divider" data-key-openapi> | |
| <summary className="set-help">OpenAPI</summary> | |
| <div className="set-field"> | |
| <span className="set-label">Document</span> | |
| {renderCode(documentUrl, "document", <a href={documentUrl}>{documentUrl}</a>)} | |
| </div> | |
| <div className="set-field"> | |
| <span className="set-label">Generate types</span> | |
| {renderCode(openApiTypesCommand(documentUrl), "command")} | |
| </div> | |
| </details> | |
| ); | |
| } | |