MCPcopy
hub / github.com/GitbookIO/gitbook / OpenAPIPath

Function OpenAPIPath

packages/react-openapi/src/OpenAPIPath.tsx:9–52  ·  view source on GitHub ↗
(props: {
    data: OpenAPIOperationData;
    context: OpenAPIUniversalContext;
    /** Whether to show the server URL.
     * @default true
     */
    withServer?: boolean;
    /**
     * Whether the path is copyable.
     * @default true
     */
    canCopy?: boolean;
})

Source from the content-addressed store, hash-verified

7 * Display the path of an operation.
8 */
9export function OpenAPIPath(props: {
10 data: OpenAPIOperationData;
11 context: OpenAPIUniversalContext;
12 /** Whether to show the server URL.
13 * @default true
14 */
15 withServer?: boolean;
16 /**
17 * Whether the path is copyable.
18 * @default true
19 */
20 canCopy?: boolean;
21}) {
22 const { data, context, withServer = true, canCopy = true } = props;
23 const { method, path, operation } = data;
24
25 const server = getDefaultServerURL(data.servers);
26 const formattedPath = formatPath(path);
27
28 const element = (() => {
29 return (
30 <>
31 {withServer ? <span className="openapi-path-server">{server}</span> : null}
32 {formattedPath}
33 </>
34 );
35 })();
36
37 return (
38 <div className="openapi-path">
39 <div className={`openapi-method openapi-method-${method}`}>{method}</div>
40
41 <OpenAPICopyButton
42 value={`${withServer ? server : ''}${path}`}
43 className="openapi-path-title"
44 data-deprecated={operation.deprecated}
45 isDisabled={!canCopy}
46 context={getOpenAPIClientContext(context)}
47 >
48 {element}
49 </OpenAPICopyButton>
50 </div>
51 );
52}
53
54/**
55 * Format the path by wrapping placeholders in <span> tags.

Callers

nothing calls this directly

Calls 3

getDefaultServerURLFunction · 0.90
getOpenAPIClientContextFunction · 0.90
formatPathFunction · 0.85

Tested by

no test coverage detected