Skip to content

Commit bb6a7cf

Browse files
committed
Dont render serverUrl on callbacks MethodEndpoint component
1 parent de1099e commit bb6a7cf

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* ============================================================================
2+
* Copyright (c) Palo Alto Networks
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
* ========================================================================== */
7+
8+
import { create } from "./utils";
9+
10+
export function createCallbackMethodEndpoint(method: String, path: String) {
11+
return [
12+
create("MethodEndpoint", {
13+
method: method,
14+
path: path,
15+
context: "callback",
16+
}),
17+
"\n\n",
18+
];
19+
}

packages/docusaurus-plugin-openapi-docs/src/markdown/createCallbacks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
* ========================================================================== */
77

8+
import { createCallbackMethodEndpoint } from "./createCallbackMethodEndpoint";
89
import { createDescription } from "./createDescription";
9-
import { createMethodEndpoint } from "./createMethodEndpoint";
1010
import { createRequestBodyDetails } from "./createRequestBodyDetails";
1111
import { createStatusCodes } from "./createStatusCodes";
1212
import { create } from "./utils";
@@ -78,7 +78,7 @@ export function createCallbacks({ callbacks }: Props) {
7878
label: `${method.toUpperCase()} ${name}`,
7979
value: `${method}-${name}`,
8080
children: [
81-
createMethodEndpoint(method, path),
81+
createCallbackMethodEndpoint(method, path),
8282
// TODO: add `deprecation notice` when markdown support is added
8383
createDescription(description),
8484
createRequestBodyDetails({

packages/docusaurus-plugin-openapi-docs/src/markdown/createMethodEndpoint.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@
88
import { create } from "./utils";
99

1010
export function createMethodEndpoint(method: String, path: String) {
11-
return [create("MethodEndpoint", { method: method, path: path }), "\n\n"];
11+
return [
12+
create("MethodEndpoint", {
13+
method: method,
14+
path: path,
15+
context: "endpoint",
16+
}),
17+
"\n\n",
18+
];
1219
}

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/MethodEndpoint/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,20 @@ function colorForMethod(method: string) {
3535
export interface Props {
3636
method: string;
3737
path: string;
38+
context?: "endpoint" | "callback";
3839
}
3940

40-
function MethodEndpoint({ method, path }: Props) {
41+
function MethodEndpoint({ method, path, context }: Props) {
42+
const server = useTypedSelector((state: any) => state);
43+
4144
let serverValue = useTypedSelector((state: any) => state.server.value);
4245
let serverUrlWithVariables = "";
4346

4447
const renderServerUrl = () => {
48+
if (context === "callback") {
49+
return "";
50+
}
51+
4552
if (serverValue && serverValue.variables) {
4653
serverUrlWithVariables = serverValue.url.replace(/\/$/, "");
4754

0 commit comments

Comments
 (0)