import { availableTargets } from '@readme/httpsnippet'; import { HttpMethod, OpenAPIParameterData, OpenAPIRequestBodyData, OpenAPISecuritySchemeData, OpenAPIServerData } from '../types/openapi'; /** The dropdown opens on httpsnippet's "agent" target: a prompt meant to be * pasted into an AI assistant rather than run. It's language-agnostic, so * it's the one option that's useful to every reader regardless of what * they're building in. `CodeSamples.tsx` overrides this specific * target/client's generated content with the constructed endpoint Markdown * (`openApiEndpointToMarkdown`) rather than httpsnippet's own terser * built-in agent prompt — the target/client catalog entry (key, title, * position in the dropdown) still comes from httpsnippet's registry below, * only the generated snippet body is swapped out. */ export declare const DEFAULT_CODE_SAMPLE_TARGET = "agent"; export declare const DEFAULT_CODE_SAMPLE_CLIENT = "prompt"; export type AvailableCodeSampleTarget = ReturnType[number]; /** Every target/client @readme/httpsnippet knows how to generate (curl, * fetch, axios, Python requests, Go, Rust, ...), grouped by target — this is * the data source for the language/library dropdown. Pure passthrough kept * here so `@readme/httpsnippet` stays imported in one place. */ export declare function getAvailableCodeSampleTargets(): AvailableCodeSampleTarget[]; interface HarNameValue { name: string; value: string; } /** Loosely-typed HAR request we build ourselves — @readme/httpsnippet's own * `HarRequest` type (from @types/har-format) declares several fields as * required that its `init()` step actually defaults for us at runtime * (httpVersion, headers, cookies, queryString, postData.mimeType). We build * only what we need and cast at the single call site in `generateSnippet`. */ export interface CodeSampleHarRequest { method: string; url: string; httpVersion: string; headers: HarNameValue[]; queryString: HarNameValue[]; cookies: HarNameValue[]; postData?: { mimeType: string; text: string; }; } interface ResolvedAuthPlaceholder { location: "header" | "query" | "cookie"; name: string; value: string; } interface ResolvedRequestBodyMedia { contentType: string; schema?: unknown; authorExample?: unknown; } /** Substitutes each `{var}` in a server URL template with its declared * default (or first enum value, or the literal token as a last resort). * Falls back to a placeholder host when the operation has no server at all, * since HTTPSnippet's clients require an absolute URL. */ export declare function resolveServerBaseUrl(servers?: OpenAPIServerData[]): string; /** Precedence: `param.example` → first `param.examples[...].value` → * `schema.example` → first `schema.enum` value → a literal `{name}` token as * a last-resort placeholder, so an undocumented parameter still produces a * valid, copyable (if not runnable as-is) sample. */ export declare function resolveParamExampleValue(param: OpenAPIParameterData): string; /** Substitutes `{token}` path placeholders using the matching `in: "path"` * parameter's example value. Falls back to the literal token when no * matching parameter is supplied — this is what keeps the sample valid even * for operations whose path parameter is only declared at the path-item * level (not merged into `op.parameters` today). */ export declare function buildRequestUrl(baseUrl: string, path: string, parameters: OpenAPIParameterData[]): string; /** Resolves the first `security`/`globalSecurity` OR-alternative against * `components.securitySchemes` into placeholder auth values, routed by * location (header/query/cookie) so the caller can feed them into the * matching HAR array. First code in the library to actually resolve a * security requirement against its scheme definition. */ export declare function resolveAuthPlaceholders(security: Array>, securitySchemes?: Record): ResolvedAuthPlaceholder[]; /** Picks the request body media type to sample: prefers `application/json`, * else the first declared content type. Surfaces the author-supplied * `example`/`examples` value (never read anywhere else in the codebase * today) so the caller can prefer it over a schema-faker-generated one. */ export declare function pickRequestBodyMedia(requestBody?: OpenAPIRequestBodyData): ResolvedRequestBodyMedia | null; interface BuildHarRequestInput { method: HttpMethod; path: string; servers?: OpenAPIServerData[]; parameters: OpenAPIParameterData[]; security: Array>; securitySchemes?: Record; media: ResolvedRequestBodyMedia | null; resolvedBodyValue: unknown; } /** Assembles a HAR request object from a resolved operation — the input to * `generateSnippet`/`@readme/httpsnippet`. Query parameters are supplied only * via the `queryString` array (not appended to `url`); HTTPSnippet's own * `prepare()` step reconstructs and encodes the final URL from that array. */ export declare function buildHarRequest(input: BuildHarRequestInput): CodeSampleHarRequest; /** Generates a single target/client code sample for a resolved HAR request * via @readme/httpsnippet. Fails soft: an unsupported target/client pair or a * malformed request resolves to an empty string rather than throwing, so one * bad operation (or a stale dropdown selection) can't crash the panel. * `target`/`client` come from `getAvailableCodeSampleTargets()`'s own keys, so * they're always valid at the httpsnippet level — the cast below only works * around TargetId/ClientId not being exported types we can name directly. */ export declare function generateSnippet(harRequest: CodeSampleHarRequest, target: string, client: string): string; export {};