UNPKG

@scalar/api-client

Version:

the open source API testing client

133 lines 4.54 kB
import type { HttpMethod as HttpMethodType } from '@scalar/helpers/http/http-methods'; import { type AvailableClients } from '@scalar/snippetz'; import { type WorkspaceEventBus } from '@scalar/workspace-store/events'; import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'; import type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'; import type { ClientOptionGroup } from '../../../../v2/blocks/operation-code-sample/types'; import type { SecuritySchemeObjectSecret } from '../../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types'; export type OperationCodeSampleProps = { /** * Integration type: determines if the code sample is displayed in a client environment * or in an API reference environment. */ integration?: 'client' | 'reference'; /** * List of all http clients formatted into option groups for the client selector */ clientOptions: ClientOptionGroup[]; /** * Pre-selected client, this will determine which client is initially selected in the dropdown * * @defaults to shell/curl or a custom sample if one is available */ selectedClient?: AvailableClients[number]; /** * Which server from the spec to use for the code example */ selectedServer?: ServerObject | null; /** * The selected content type from the requestBody.content, this will determine which examples are available * as well as the content type of the code example * * @defaults to the first content type if not provided */ selectedContentType?: string; /** * Example name to use for resolving example values for parameters AND requestBody * * @example "limited" * ```ts * parameters: { * name: 'foobar', * in: 'query', * examples: { * limited: { * dataValue: 10, * } * } * }, * body: { * content: { * 'application/json': { * examples: { * limited: { * dataValue: { foo: 'bar' }, * } * } * } * } * } * * ``` */ selectedExample?: string; /** * Event bus */ eventBus: WorkspaceEventBus; /** * The security schemes which are applicable to this operation */ securitySchemes: SecuritySchemeObjectSecret[]; /** * HTTP method of the operation */ method: HttpMethodType; /** * Path of the operation */ path: string; /** * De-referenced OpenAPI Operation object */ operation: OperationObject; /** * If true and there's no example, we will display a small card with the method and path only */ fallback?: boolean; /** * A method to generate the label of the block, should return an html string */ generateLabel?: () => string; /** * If true, render this as a webhook request example */ isWebhook?: boolean; /** * Workspace + document cookies */ globalCookies?: XScalarCookie[]; }; /** * Request Example * * The core component for rendering a request example block, * this component does not have much of its own state but operates on props and custom events * * @event workspace:update:selected-client - Emitted when the selected client changes * @event scalar-update-selected-example - removed for now, we can bring it back when we need it */ declare const _default: typeof __VLS_export; export default _default; declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<OperationCodeSampleProps & { /** The currently selected example key with v-model support */ selectedExample?: string; }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, { "update:selectedExample": (value: string) => any; }, string, import("vue").PublicProps, Readonly<OperationCodeSampleProps & { /** The currently selected example key with v-model support */ selectedExample?: string; }> & Readonly<{ "onUpdate:selectedExample"?: ((value: string) => any) | undefined; }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, { header: () => unknown; footer: ({ exampleName }: { exampleName: string; }) => unknown; }>; type __VLS_WithSlots<T, S> = T & { new (): { $slots: S; }; }; //# sourceMappingURL=OperationCodeSample.vue.d.ts.map