docusaurus-theme-openapi-docs 0.0.0-1087 → 0.0.0-1088

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -259,7 +259,7 @@ function Request({ item }) {
259
259
  const showServerOptions = serverOptions.length > 0;
260
260
  const showAcceptOptions = acceptOptions.length > 1;
261
261
  const showRequestBody = contentType !== undefined;
262
- const showRequestButton = item.servers && !hideSendButton;
262
+ const showRequestButton = (item.servers || proxy) && !hideSendButton;
263
263
  const showAuth = authSelected !== undefined;
264
264
  const showParams = allParams.length > 0;
265
265
  const requestBodyRequired = item.requestBody?.required;
@@ -268,7 +268,8 @@ function Request({ item }) {
268
268
  !showAuth &&
269
269
  !showParams &&
270
270
  !showRequestBody &&
271
- !showServerOptions
271
+ !showServerOptions &&
272
+ !showRequestButton
272
273
  ) {
273
274
  return null;
274
275
  }
@@ -15,6 +15,9 @@ const react_1 = __importDefault(require("react"));
15
15
  const client_1 = require("@docusaurus/plugin-content-docs/client");
16
16
  const theme_common_1 = require("@docusaurus/theme-common");
17
17
  const Translate_1 = require("@docusaurus/Translate");
18
+ const useDocusaurusContext_1 = __importDefault(
19
+ require("@docusaurus/useDocusaurusContext")
20
+ );
18
21
  const ApiCodeBlock_1 = __importDefault(
19
22
  require("@theme/ApiExplorer/ApiCodeBlock")
20
23
  );
@@ -44,7 +47,10 @@ function formatXml(xml) {
44
47
  }
45
48
  function Response({ item }) {
46
49
  const metadata = (0, client_1.useDoc)();
50
+ const { siteConfig } = (0, useDocusaurusContext_1.default)();
51
+ const themeConfig = siteConfig.themeConfig;
47
52
  const hideSendButton = metadata.frontMatter.hide_send_button;
53
+ const proxy = metadata.frontMatter.proxy ?? themeConfig.api?.proxy;
48
54
  const prismTheme = (0, theme_common_1.usePrismTheme)();
49
55
  const code = (0, hooks_1.useTypedSelector)((state) => state.response.code);
50
56
  const headers = (0, hooks_1.useTypedSelector)(
@@ -62,7 +68,7 @@ function Response({ item }) {
62
68
  : parseInt(code) >= 200 && parseInt(code) < 300
63
69
  ? "openapi-response__dot--success"
64
70
  : "openapi-response__dot--info");
65
- if (!item.servers || hideSendButton) {
71
+ if ((!item.servers && !proxy) || hideSendButton) {
66
72
  return null;
67
73
  }
68
74
  let prettyResponse = response;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "0.0.0-1087",
4
+ "version": "0.0.0-1088",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -38,7 +38,7 @@
38
38
  "@types/postman-collection": "^3.5.11",
39
39
  "@types/react-modal": "^3.16.3",
40
40
  "concurrently": "^9.2.0",
41
- "docusaurus-plugin-openapi-docs": "0.0.0-1087",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1088",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -81,5 +81,5 @@
81
81
  "engines": {
82
82
  "node": ">=14"
83
83
  },
84
- "gitHead": "756f11daaa891d07bd433737d66f72b6167e3a88"
84
+ "gitHead": "6ec4b44faad96aeb9c31ab6086eee3a6886ac69f"
85
85
  }
@@ -11,7 +11,6 @@ import React, { useState } from "react";
11
11
  import { useDoc } from "@docusaurus/plugin-content-docs/client";
12
12
  import { translate } from "@docusaurus/Translate";
13
13
  import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
14
- import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
15
14
  import Accept from "@theme/ApiExplorer/Accept";
16
15
  import Authorization from "@theme/ApiExplorer/Authorization";
17
16
  import Body from "@theme/ApiExplorer/Body";
@@ -30,6 +29,7 @@ import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
30
29
  import { OPENAPI_REQUEST } from "@theme/translationIds";
31
30
  import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
32
31
  import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
32
+ import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
33
33
  import * as sdk from "postman-collection";
34
34
  import { FormProvider, useForm } from "react-hook-form";
35
35
 
@@ -200,7 +200,7 @@ function Request({ item }: { item: ApiItem }) {
200
200
  const showServerOptions = serverOptions.length > 0;
201
201
  const showAcceptOptions = acceptOptions.length > 1;
202
202
  const showRequestBody = contentType !== undefined;
203
- const showRequestButton = item.servers && !hideSendButton;
203
+ const showRequestButton = (item.servers || proxy) && !hideSendButton;
204
204
  const showAuth = authSelected !== undefined;
205
205
  const showParams = allParams.length > 0;
206
206
  const requestBodyRequired = item.requestBody?.required;
@@ -210,7 +210,8 @@ function Request({ item }: { item: ApiItem }) {
210
210
  !showAuth &&
211
211
  !showParams &&
212
212
  !showRequestBody &&
213
- !showServerOptions
213
+ !showServerOptions &&
214
+ !showRequestButton
214
215
  ) {
215
216
  return null;
216
217
  }
@@ -10,6 +10,7 @@ import React from "react";
10
10
  import { useDoc } from "@docusaurus/plugin-content-docs/client";
11
11
  import { usePrismTheme } from "@docusaurus/theme-common";
12
12
  import { translate } from "@docusaurus/Translate";
13
+ import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
13
14
  import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
14
15
  import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
15
16
  import SchemaTabs from "@theme/SchemaTabs";
@@ -17,6 +18,7 @@ import TabItem from "@theme/TabItem";
17
18
  import { OPENAPI_RESPONSE } from "@theme/translationIds";
18
19
  import clsx from "clsx";
19
20
  import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
21
+ import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
20
22
 
21
23
  import { clearResponse, clearCode, clearHeaders } from "./slice";
22
24
 
@@ -42,7 +44,11 @@ function formatXml(xml: string) {
42
44
 
43
45
  function Response({ item }: { item: ApiItem }) {
44
46
  const metadata = useDoc();
47
+ const { siteConfig } = useDocusaurusContext();
48
+ const themeConfig = siteConfig.themeConfig as ThemeConfig;
45
49
  const hideSendButton = metadata.frontMatter.hide_send_button;
50
+ const proxy =
51
+ metadata.frontMatter.proxy ?? themeConfig.api?.proxy;
46
52
  const prismTheme = usePrismTheme();
47
53
  const code = useTypedSelector((state: any) => state.response.code);
48
54
  const headers = useTypedSelector((state: any) => state.response.headers);
@@ -57,7 +63,7 @@ function Response({ item }: { item: ApiItem }) {
57
63
  ? "openapi-response__dot--success"
58
64
  : "openapi-response__dot--info");
59
65
 
60
- if (!item.servers || hideSendButton) {
66
+ if ((!item.servers && !proxy) || hideSendButton) {
61
67
  return null;
62
68
  }
63
69