@deepgram/deepdown-utils
Version:
Utility functions for Deepdown markdown templating
81 lines (80 loc) • 2.3 kB
TypeScript
/**
* Utility for generating curl authentication examples
* Compatible with both OpenAPI and AsyncAPI security schemes
*/
/**
* Common Security Scheme Type Interface
* Covers both OpenAPI and AsyncAPI security schemes
*/
export interface SecurityScheme {
type: string;
name?: string;
in?: string;
scheme?: string;
bearerFormat?: string;
flows?: Record<string, any>;
openIdConnectUrl?: string;
[key: string]: any;
}
/**
* Security Requirement with required scopes
*/
export interface SecurityRequirement {
name: string;
scopes?: string[];
scheme: SecurityScheme;
}
/**
* Output format for curl auth examples
*/
export interface CurlAuthExample {
headers?: Array<{
name: string;
value: string;
}>;
queryParams?: Array<{
name: string;
value: string;
}>;
cookies?: Array<{
name: string;
value: string;
}>;
basicAuth?: {
username: string;
password: string;
};
description: string;
}
/**
* Options for generating curl examples
*/
export interface CurlExampleOptions {
includeComments?: boolean;
placeholderStyle?: 'uppercase' | 'camelCase' | 'placeholder';
useShortFlags?: boolean;
indentSize?: number;
}
/**
* Generates curl authentication examples for a security scheme
*/
export declare function generateCurlAuth(securityRequirement: SecurityRequirement, options?: CurlExampleOptions): CurlAuthExample;
/**
* Formats auth information as curl command-line arguments
*/
export declare function formatCurlAuthArgs(auth: CurlAuthExample, options?: CurlExampleOptions): string;
/**
* Formats the full curl command including URL and query parameters
*/
export declare function formatCurlCommand(url: string, auth: CurlAuthExample, options?: CurlExampleOptions): string;
/**
* Creates a Handlebars helper function for use in templates
*/
export declare function createCurlAuthHelper(): (securityScheme: SecurityScheme, securityName: string, scopes?: string[]) => string;
declare const _default: {
generateCurlAuth: typeof generateCurlAuth;
formatCurlAuthArgs: typeof formatCurlAuthArgs;
formatCurlCommand: typeof formatCurlCommand;
createCurlAuthHelper: typeof createCurlAuthHelper;
};
export default _default;