UNPKG

@redocly/theme

Version:

Shared UI components lib

109 lines (96 loc) 2.8 kB
import { UserClaims, OpenAPIServer } from '@redocly/theme'; export type SecurityDetails = { password?: string; username?: string; token?: { token_type?: string; access_token: string; }; client_id?: string; client_secret?: string; scopes?: string[]; }; export type ConfigureRequestValues = { headers?: Record<string, string>; body?: Record<string, any>; query?: Record<string, string>; path?: Record<string, string>; cookie?: Record<string, string>; security?: SecurityDetails; envVariables?: Record<string, string>; }; export type ConfigureServerRequestValues = { [serverUrl: string]: ConfigureRequestValues; }; type Configure = { requestValues?: ConfigureRequestValues | ConfigureServerRequestValues; }; type ContextProps = { userClaims?: UserClaims; operation: { name: string; path: string; operationId?: string; href?: string; method: string; }; servers: OpenAPIServer[]; }; export function configure(_context: ContextProps): Configure { // const exampleDefaultRequestValues: ConfigureRequestValues = { // body: { // name: 'Default Product' // }, // security: { // username: 'default_api_user', // password: 'secureP@ssword123' // }, // envVariables: { // customLocation: 'default' // }, // }; // const exampleDevRequestValues: ConfigureRequestValues = { // body: { // name: 'Development Product' // }, // security: { // username: 'dev_api_user', // password: 'Dev@P!T3st' // }, // envVariables: { // customLocation: 'dev' // }, // }; // const exampleProdRequestValues: ConfigureRequestValues = { // body: { // name: 'Production Product' // }, // security: { // username: 'prod_api_user', // password: 'Pr0d@P!S3cur3' // }, // envVariables: { // customLocation: 'prod' // }, // }; // const { servers } = _context; // const serverRequestValues: ConfigureServerRequestValues = {}; // for (const server of servers) { // if (server.url === 'https://dev.api.fake-museum-example.com') { // serverRequestValues[server.url] = exampleDevRequestValues; // } else if (server.url === 'https://api.fake-museum-example.com') { // serverRequestValues[server.url] = exampleProdRequestValues; // } else { // serverRequestValues[server.url] = exampleDefaultRequestValues; // } // } // Uncomment the following to use default request values for all servers // return { // requestValues: exampleDefaultRequestValues, // } satisfies Configure; // Uncomment the following to use server-specific request values // return { // requestValues: serverRequestValues // } satisfies Configure; return {} satisfies Configure; }