docusaurus-theme-openapi-docs 0.0.0-362 → 0.0.0-365

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.
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _Link = _interopRequireDefault(require("@docusaurus/Link"));
11
+
10
12
  var _hooks = require("../hooks");
11
13
 
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -17,9 +19,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
19
  * This source code is licensed under the MIT license found in the
18
20
  * LICENSE file in the root directory of this source tree.
19
21
  * ========================================================================== */
20
- function SecuritySchemes() {
22
+ function SecuritySchemes(props) {
21
23
  const options = (0, _hooks.useTypedSelector)(state => state.auth.options);
22
24
  const selected = (0, _hooks.useTypedSelector)(state => state.auth.selected);
25
+ const infoAuthPath = `/${props.infoPath}#authentication`;
23
26
  if (selected === undefined) return null;
24
27
  const selectedAuth = options[selected];
25
28
  return <div style={{
@@ -32,7 +35,9 @@ function SecuritySchemes() {
32
35
 
33
36
  if (isApiKey || isBearer) {
34
37
  return <_react.default.Fragment key={selected}>
35
- <b>Authorization: {auth.key}</b>
38
+ <b>
39
+ Authorization: <_Link.default to={infoAuthPath}>{auth.key}</_Link.default>
40
+ </b>
36
41
  <pre style={{
37
42
  display: "flex",
38
43
  flexDirection: "column",
@@ -46,7 +46,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
46
  * LICENSE file in the root directory of this source tree.
47
47
  * ========================================================================== */
48
48
  function ApiDemoPanel({
49
- item
49
+ item,
50
+ infoPath
50
51
  }) {
51
52
  var _item$responses, _item$requestBody$con, _item$requestBody, _item$servers, _item$parameters, _xCodeSamples;
52
53
 
@@ -110,19 +111,14 @@ function ApiDemoPanel({
110
111
  return <_reactRedux.Provider store={store2}>
111
112
  <div className={_stylesModule.default.apiDemoPanelContainer}>
112
113
  <_MethodEndpoint.default method={method} path={path} />
113
-
114
- <_SecuritySchemes.default />
115
-
114
+ <_SecuritySchemes.default infoPath={infoPath} />
116
115
  <div className={_stylesModule.default.optionsPanel}>
117
116
  <_ParamOptions.default />
118
117
  <_Body.default jsonRequestBodyExample={item.jsonRequestBodyExample} requestBodyMetadata={item.requestBody} />
119
118
  <_Accept.default />
120
119
  </div>
121
-
122
120
  <_Server.default />
123
-
124
121
  <_Curl.default postman={postman} codeSamples={(_xCodeSamples = item["x-code-samples"]) !== null && _xCodeSamples !== void 0 ? _xCodeSamples : []} />
125
-
126
122
  <_Response.default />
127
123
  </div>
128
124
  </_reactRedux.Provider>;
@@ -85,6 +85,7 @@ function DocItemContent(props) {
85
85
  frontMatter
86
86
  } = DocContent;
87
87
  const {
88
+ info_path: infoPath,
88
89
  hide_title: hideTitle,
89
90
  hide_table_of_contents: hideTableOfContents,
90
91
  toc_min_heading_level: tocMinHeadingLevel,
@@ -131,7 +132,7 @@ function DocItemContent(props) {
131
132
  <DocContent />
132
133
  </div>
133
134
  {api && <div className="col col--5">
134
- <ApiDemoPanel item={api} />
135
+ <ApiDemoPanel item={api} infoPath={infoPath} />
135
136
  </div>}
136
137
  </div>
137
138
  </_MDXContent.default>
@@ -5,11 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
  import React from "react";
8
+ import Link from "@docusaurus/Link";
8
9
  import { useTypedSelector } from "../hooks";
9
10
 
10
- function SecuritySchemes() {
11
+ function SecuritySchemes(props) {
11
12
  const options = useTypedSelector((state) => state.auth.options);
12
13
  const selected = useTypedSelector((state) => state.auth.selected);
14
+ const infoAuthPath = `/${props.infoPath}#authentication`;
13
15
  if (selected === undefined) return null;
14
16
  const selectedAuth = options[selected];
15
17
  return (
@@ -27,7 +29,9 @@ function SecuritySchemes() {
27
29
  if (isApiKey || isBearer) {
28
30
  return (
29
31
  <React.Fragment key={selected}>
30
- <b>Authorization: {auth.key}</b>
32
+ <b>
33
+ Authorization: <Link to={infoAuthPath}>{auth.key}</Link>
34
+ </b>
31
35
  <pre
32
36
  style={{
33
37
  display: "flex",
@@ -21,7 +21,7 @@ import Server from "./Server";
21
21
  import { createStoreWithState } from "./store";
22
22
  import styles from "./styles.module.css";
23
23
 
24
- function ApiDemoPanel({ item }) {
24
+ function ApiDemoPanel({ item, infoPath }) {
25
25
  const { siteConfig } = useDocusaurusContext();
26
26
  const themeConfig = siteConfig.themeConfig;
27
27
  const options = themeConfig.api;
@@ -83,9 +83,7 @@ function ApiDemoPanel({ item }) {
83
83
  <Provider store={store2}>
84
84
  <div className={styles.apiDemoPanelContainer}>
85
85
  <MethodEndpoint method={method} path={path} />
86
-
87
- <SecuritySchemes />
88
-
86
+ <SecuritySchemes infoPath={infoPath} />
89
87
  <div className={styles.optionsPanel}>
90
88
  <ParamOptions />
91
89
  <Body
@@ -94,11 +92,8 @@ function ApiDemoPanel({ item }) {
94
92
  />
95
93
  <Accept />
96
94
  </div>
97
-
98
95
  <Server />
99
-
100
96
  <Curl postman={postman} codeSamples={item["x-code-samples"] ?? []} />
101
-
102
97
  <Response />
103
98
  </div>
104
99
  </Provider>
@@ -58,6 +58,7 @@ function DocItemContent(props) {
58
58
  const { content: DocContent } = props;
59
59
  const { metadata, frontMatter } = DocContent;
60
60
  const {
61
+ info_path: infoPath,
61
62
  hide_title: hideTitle,
62
63
  hide_table_of_contents: hideTableOfContents,
63
64
  toc_min_heading_level: tocMinHeadingLevel,
@@ -121,7 +122,7 @@ function DocItemContent(props) {
121
122
  </div>
122
123
  {api && (
123
124
  <div className="col col--5">
124
- <ApiDemoPanel item={api} />
125
+ <ApiDemoPanel item={api} infoPath={infoPath} />
125
126
  </div>
126
127
  )}
127
128
  </div>
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-362",
4
+ "version": "0.0.0-365",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -51,7 +51,7 @@
51
51
  "buffer": "^6.0.3",
52
52
  "clsx": "^1.1.1",
53
53
  "crypto-js": "^4.1.1",
54
- "docusaurus-plugin-openapi-docs": "0.0.0-362",
54
+ "docusaurus-plugin-openapi-docs": "0.0.0-365",
55
55
  "immer": "^9.0.7",
56
56
  "lodash": "^4.17.20",
57
57
  "monaco-editor": "^0.31.1",
@@ -70,5 +70,5 @@
70
70
  "engines": {
71
71
  "node": ">=14"
72
72
  },
73
- "gitHead": "b887778ce634dfbc7f723721ffacef03679cec7e"
73
+ "gitHead": "f9390cc5f7f74c629f45bb374c26dac169deb797"
74
74
  }
@@ -7,11 +7,14 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
+ import Link from "@docusaurus/Link";
11
+
10
12
  import { useTypedSelector } from "../hooks";
11
13
 
12
- function SecuritySchemes() {
14
+ function SecuritySchemes(props: any) {
13
15
  const options = useTypedSelector((state) => state.auth.options);
14
16
  const selected = useTypedSelector((state) => state.auth.selected);
17
+ const infoAuthPath = `/${props.infoPath}#authentication`;
15
18
 
16
19
  if (selected === undefined) return null;
17
20
 
@@ -28,7 +31,9 @@ function SecuritySchemes() {
28
31
  if (isApiKey || isBearer) {
29
32
  return (
30
33
  <React.Fragment key={selected}>
31
- <b>Authorization: {auth.key}</b>
34
+ <b>
35
+ Authorization: <Link to={infoAuthPath}>{auth.key}</Link>
36
+ </b>
32
37
  <pre
33
38
  style={{
34
39
  display: "flex",
@@ -27,7 +27,13 @@ import Server from "./Server";
27
27
  import { createStoreWithState } from "./store";
28
28
  import styles from "./styles.module.css";
29
29
 
30
- function ApiDemoPanel({ item }: { item: NonNullable<ApiItem> }) {
30
+ function ApiDemoPanel({
31
+ item,
32
+ infoPath,
33
+ }: {
34
+ item: NonNullable<ApiItem>;
35
+ infoPath: string;
36
+ }) {
31
37
  const { siteConfig } = useDocusaurusContext();
32
38
  const themeConfig = siteConfig.themeConfig as ThemeConfig;
33
39
  const options = themeConfig.api;
@@ -89,9 +95,7 @@ function ApiDemoPanel({ item }: { item: NonNullable<ApiItem> }) {
89
95
  <Provider store={store2}>
90
96
  <div className={styles.apiDemoPanelContainer}>
91
97
  <MethodEndpoint method={method} path={path} />
92
-
93
- <SecuritySchemes />
94
-
98
+ <SecuritySchemes infoPath={infoPath} />
95
99
  <div className={styles.optionsPanel}>
96
100
  <ParamOptions />
97
101
  <Body
@@ -100,14 +104,11 @@ function ApiDemoPanel({ item }: { item: NonNullable<ApiItem> }) {
100
104
  />
101
105
  <Accept />
102
106
  </div>
103
-
104
107
  <Server />
105
-
106
108
  <Curl
107
109
  postman={postman}
108
110
  codeSamples={(item as any)["x-code-samples"] ?? []}
109
111
  />
110
-
111
112
  <Response />
112
113
  </div>
113
114
  </Provider>
@@ -30,7 +30,9 @@ import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/lib/
30
30
  import { DocFrontMatter } from "../../types";
31
31
  import styles from "./styles.module.css";
32
32
 
33
- let ApiDemoPanel = (_: { item: any }) => <div style={{ marginTop: "3.5em" }} />;
33
+ let ApiDemoPanel = (_: { item: any; infoPath: any }) => (
34
+ <div style={{ marginTop: "3.5em" }} />
35
+ );
34
36
  if (ExecutionEnvironment.canUseDOM) {
35
37
  ApiDemoPanel = require("@theme/ApiDemoPanel").default;
36
38
  }
@@ -53,11 +55,12 @@ function DocItemContent(props: Props): JSX.Element {
53
55
  const { content: DocContent } = props;
54
56
  const { metadata, frontMatter } = DocContent;
55
57
  const {
58
+ info_path: infoPath,
56
59
  hide_title: hideTitle,
57
60
  hide_table_of_contents: hideTableOfContents,
58
61
  toc_min_heading_level: tocMinHeadingLevel,
59
62
  toc_max_heading_level: tocMaxHeadingLevel,
60
- } = frontMatter;
63
+ } = frontMatter as DocFrontMatter;
61
64
  const { title } = metadata;
62
65
 
63
66
  const { api } = frontMatter as ApiFrontMatter;
@@ -122,7 +125,7 @@ function DocItemContent(props: Props): JSX.Element {
122
125
  </div>
123
126
  {api && (
124
127
  <div className="col col--5">
125
- <ApiDemoPanel item={api} />
128
+ <ApiDemoPanel item={api} infoPath={infoPath} />
126
129
  </div>
127
130
  )}
128
131
  </div>
package/src/types.ts CHANGED
@@ -177,4 +177,6 @@ export type DocFrontMatter = {
177
177
  draft?: boolean;
178
178
  /** Allows overriding the last updated author and/or date. */
179
179
  last_update?: FileChange;
180
+ /** Provides OpenAPI Docs with a reference path to their respective Info Doc */
181
+ info_path?: string;
180
182
  };