docusaurus-theme-openapi-docs 1.1.12 → 1.2.1

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.
Files changed (67) hide show
  1. package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +4 -0
  2. package/lib/theme/ApiDemoPanel/Authorization/index.js +125 -0
  3. package/lib/theme/ApiDemoPanel/Authorization/slice.js +1 -1
  4. package/lib/theme/ApiDemoPanel/Body/index.js +7 -6
  5. package/lib/theme/ApiDemoPanel/Execute/index.js +168 -0
  6. package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +204 -0
  7. package/lib/theme/ApiDemoPanel/FormItem/index.js +7 -0
  8. package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +5 -0
  9. package/lib/theme/ApiDemoPanel/ParamOptions/index.js +1 -1
  10. package/lib/theme/ApiDemoPanel/Request/index.js +78 -0
  11. package/lib/theme/ApiDemoPanel/Request/styles.module.css +17 -0
  12. package/lib/theme/ApiDemoPanel/Response/index.js +16 -12
  13. package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +24 -19
  14. package/lib/theme/ApiDemoPanel/Server/index.js +1 -0
  15. package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +25 -3
  16. package/lib/theme/ApiDemoPanel/index.js +5 -13
  17. package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +1 -1
  18. package/lib/theme/ApiDemoPanel/react-modal.d.ts +8 -0
  19. package/lib/theme/ApiItem/Layout/styles.module.css +56 -0
  20. package/lib/theme/ApiTabs/styles.module.css +9 -5
  21. package/lib/theme/ParamsItem/index.js +5 -1
  22. package/lib/theme/SchemaTabs/styles.module.css +10 -6
  23. package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +4 -0
  24. package/lib-next/theme/ApiDemoPanel/Authorization/index.js +149 -0
  25. package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +1 -1
  26. package/lib-next/theme/ApiDemoPanel/Body/index.js +28 -6
  27. package/lib-next/theme/ApiDemoPanel/Execute/index.js +170 -0
  28. package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +190 -0
  29. package/lib-next/theme/ApiDemoPanel/FormItem/index.js +9 -1
  30. package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +5 -0
  31. package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +1 -1
  32. package/lib-next/theme/ApiDemoPanel/Request/index.js +60 -0
  33. package/lib-next/theme/ApiDemoPanel/Request/styles.module.css +17 -0
  34. package/lib-next/theme/ApiDemoPanel/Response/index.js +18 -13
  35. package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +22 -20
  36. package/lib-next/theme/ApiDemoPanel/Server/index.js +1 -0
  37. package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +25 -3
  38. package/lib-next/theme/ApiDemoPanel/index.js +4 -13
  39. package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +1 -1
  40. package/lib-next/theme/ApiDemoPanel/react-modal.d.ts +8 -0
  41. package/lib-next/theme/ApiItem/Layout/styles.module.css +56 -0
  42. package/lib-next/theme/ApiTabs/styles.module.css +9 -5
  43. package/lib-next/theme/ParamsItem/index.js +5 -1
  44. package/lib-next/theme/SchemaTabs/styles.module.css +10 -6
  45. package/package.json +5 -4
  46. package/src/theme/ApiDemoPanel/Authorization/auth-types.ts +4 -0
  47. package/src/theme/ApiDemoPanel/Authorization/index.tsx +154 -0
  48. package/src/theme/ApiDemoPanel/Authorization/slice.ts +1 -1
  49. package/src/theme/ApiDemoPanel/Body/index.tsx +28 -6
  50. package/src/theme/ApiDemoPanel/Execute/index.tsx +188 -0
  51. package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +197 -0
  52. package/src/theme/ApiDemoPanel/FormItem/index.tsx +11 -2
  53. package/src/theme/ApiDemoPanel/FormItem/styles.module.css +5 -0
  54. package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +1 -1
  55. package/src/theme/ApiDemoPanel/Request/index.tsx +71 -0
  56. package/src/theme/ApiDemoPanel/Request/styles.module.css +17 -0
  57. package/src/theme/ApiDemoPanel/Response/index.tsx +19 -13
  58. package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +22 -17
  59. package/src/theme/ApiDemoPanel/Server/index.tsx +1 -0
  60. package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +22 -3
  61. package/src/theme/ApiDemoPanel/index.tsx +4 -13
  62. package/src/theme/ApiDemoPanel/persistanceMiddleware.ts +1 -1
  63. package/src/theme/ApiDemoPanel/react-modal.d.ts +8 -0
  64. package/src/theme/ApiItem/Layout/styles.module.css +56 -0
  65. package/src/theme/ApiTabs/styles.module.css +9 -5
  66. package/src/theme/ParamsItem/index.js +5 -1
  67. package/src/theme/SchemaTabs/styles.module.css +10 -6
@@ -261,6 +261,25 @@ function buildPostmanRequest(
261
261
  continue;
262
262
  }
263
263
 
264
+ if (a.type === "oauth2") {
265
+ let token;
266
+ if (auth.data[a.key]) {
267
+ token = auth.data[a.key].token;
268
+ }
269
+ if (token === undefined) {
270
+ otherHeaders.push({
271
+ key: "Authorization",
272
+ value: "Bearer <TOKEN>",
273
+ });
274
+ continue;
275
+ }
276
+ otherHeaders.push({
277
+ key: "Authorization",
278
+ value: `Bearer ${token}`,
279
+ });
280
+ continue;
281
+ }
282
+
264
283
  // Basic Auth
265
284
  if (a.type === "http" && a.scheme === "basic") {
266
285
  const { username, password } = auth.data[a.key];
@@ -276,8 +295,8 @@ function buildPostmanRequest(
276
295
 
277
296
  // API Key
278
297
  if (a.type === "apiKey" && a.in === "header") {
279
- const { apikey } = auth.data[a.key];
280
- if (apikey === undefined) {
298
+ const { apiKey } = auth.data[a.key];
299
+ if (apiKey === undefined) {
281
300
  otherHeaders.push({
282
301
  key: a.name,
283
302
  value: "<API_KEY_VALUE>",
@@ -286,7 +305,7 @@ function buildPostmanRequest(
286
305
  }
287
306
  otherHeaders.push({
288
307
  key: a.name,
289
- value: apikey,
308
+ value: apiKey,
290
309
  });
291
310
  continue;
292
311
  }
@@ -14,13 +14,11 @@ import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
14
14
  import { Provider } from "react-redux";
15
15
 
16
16
  import { ThemeConfig } from "../../types";
17
- import Accept from "./Accept";
18
17
  import { createAuth } from "./Authorization/slice";
19
- import Body from "./Body";
20
18
  import Curl from "./Curl";
21
19
  import MethodEndpoint from "./MethodEndpoint";
22
- import ParamOptions from "./ParamOptions";
23
20
  import { createPersistanceMiddleware } from "./persistanceMiddleware";
21
+ import Request from "./Request";
24
22
  import Response from "./Response";
25
23
  import SecuritySchemes from "./SecuritySchemes";
26
24
  import Server from "./Server";
@@ -95,21 +93,14 @@ function ApiDemoPanel({
95
93
  <Provider store={store2}>
96
94
  <div className={styles.apiDemoPanelContainer}>
97
95
  <MethodEndpoint method={method} path={path} />
98
- <SecuritySchemes infoPath={infoPath} />
99
- <div className={styles.optionsPanel}>
100
- <ParamOptions />
101
- <Body
102
- jsonRequestBodyExample={item.jsonRequestBodyExample}
103
- requestBodyMetadata={item.requestBody}
104
- />
105
- <Accept />
106
- </div>
107
96
  <Server />
97
+ <SecuritySchemes infoPath={infoPath} />
98
+ <Request item={item} />
99
+ <Response />
108
100
  <Curl
109
101
  postman={postman}
110
102
  codeSamples={(item as any)["x-code-samples"] ?? []}
111
103
  />
112
- <Response />
113
104
  </div>
114
105
  </Provider>
115
106
  );
@@ -19,7 +19,7 @@ export function createPersistanceMiddleware(options: ThemeConfig["api"]) {
19
19
 
20
20
  const state = storeAPI.getState();
21
21
 
22
- const storage = createStorage(options?.authPersistance);
22
+ const storage = createStorage("sessionStorage");
23
23
 
24
24
  if (action.type === setAuthData.type) {
25
25
  for (const [key, value] of Object.entries(state.auth.data)) {
@@ -0,0 +1,8 @@
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
+ declare module "react-modal";
@@ -71,6 +71,62 @@
71
71
  border-top: unset !important;
72
72
  }
73
73
 
74
+ :global(.theme-api-markdown .details__demo-panel) {
75
+ margin-bottom: 1rem;
76
+ background: var(--openapi-card-background-color);
77
+ border-radius: var(--openapi-card-border-radius);
78
+ }
79
+
80
+ :global(.theme-api-markdown .details__demo-panel > summary) {
81
+ padding-left: 1rem;
82
+ padding-top: 1rem;
83
+ cursor: pointer;
84
+ }
85
+
86
+ :global(.theme-api-markdown .details__demo-panel > div > div > pre) {
87
+ border-top-left-radius: 0;
88
+ border-top-right-radius: 0;
89
+ }
90
+
91
+ :global(.theme-api-markdown .details__demo-panel > summary::marker) {
92
+ display: none;
93
+ content: "";
94
+ }
95
+
96
+ :global(.theme-api-markdown
97
+ .details__demo-panel
98
+ > summary::-webkit-details-marker) {
99
+ display: none;
100
+ content: "";
101
+ }
102
+
103
+ :global(.theme-api-markdown .details__demo-panel > pre) {
104
+ margin-bottom: 0;
105
+ padding-top: 0;
106
+ }
107
+
108
+ :global(.theme-api-markdown .details__request-summary) {
109
+ display: flex;
110
+ justify-content: space-between;
111
+ align-items: center;
112
+ }
113
+
114
+ :global(.theme-api-markdown .details__request-summary > button) {
115
+ margin-bottom: 1rem;
116
+ margin-right: 1rem;
117
+ }
118
+
119
+ :global(.theme-api-markdown .details__response-summary) {
120
+ display: flex;
121
+ justify-content: space-between;
122
+ align-items: center;
123
+ }
124
+
125
+ :global(.theme-api-markdown .details__response-summary > button) {
126
+ margin-bottom: 1rem;
127
+ margin-right: 1rem;
128
+ }
129
+
74
130
  :global(.theme-api-markdown code) {
75
131
  max-width: 600px;
76
132
  max-height: 500px;
@@ -12,14 +12,19 @@
12
12
  height: 2.5rem;
13
13
  margin-top: 0 !important;
14
14
  margin-right: 0.5rem;
15
- border: 1px solid var(--openapi-code-dim-dark);
15
+ border: 1px solid var(--ifm-color-primary);
16
16
  border-radius: var(--ifm-global-radius);
17
+ color: var(--ifm-color-primary);
17
18
  font-weight: var(--ifm-font-weight-normal);
18
- color: var(--openapi-code-dim-dark);
19
+ }
20
+
21
+ .tabItem:not(.responseTabActive) {
22
+ opacity: 0.65;
19
23
  }
20
24
 
21
25
  .tabItem:hover {
22
- color: var(--ifm-color-emphasis-500) !important;
26
+ opacity: 1;
27
+ background-color: var(--ifm-color-emphasis-100);
23
28
  }
24
29
 
25
30
  .tabItem:last-child {
@@ -74,8 +79,7 @@
74
79
  }
75
80
 
76
81
  .responseTabActive {
77
- border: 1px solid var(--ifm-color-primary);
78
- color: var(--ifm-color-primary);
82
+ background-color: var(--ifm-color-emphasis-100);
79
83
  }
80
84
 
81
85
  .responseSchemaContainer {
@@ -53,7 +53,11 @@ function ParamsItem({
53
53
  ));
54
54
 
55
55
  const renderDefaultValue = guard(
56
- schema.items ? schema.items.default : schema.default,
56
+ schema && schema.items
57
+ ? schema.items.default
58
+ : schema
59
+ ? schema.default
60
+ : undefined,
57
61
  (value) => (
58
62
  <div>
59
63
  <ReactMarkdown children={`**Default value:** \`${value}\``} />
@@ -12,14 +12,19 @@
12
12
  height: 1.8rem;
13
13
  margin-top: 0 !important;
14
14
  margin-right: 0.5rem;
15
- border: 1px solid var(--openapi-code-dim-dark);
15
+ border: 1px solid var(--ifm-color-primary);
16
16
  border-radius: var(--ifm-global-radius);
17
- color: var(--openapi-code-dim-dark);
17
+ color: var(--ifm-color-primary);
18
18
  font-size: 12px;
19
19
  }
20
20
 
21
+ .tabItem:not(.schemaTabActive) {
22
+ opacity: 0.65;
23
+ }
24
+
21
25
  .tabItem:hover {
22
- color: var(--ifm-color-emphasis-500) !important;
26
+ opacity: 1;
27
+ background-color: var(--ifm-color-emphasis-100);
23
28
  }
24
29
 
25
30
  .tabItem:last-child {
@@ -49,9 +54,8 @@
49
54
  display: none;
50
55
  }
51
56
 
52
- .tabItem.schemaTabActive {
53
- border: 1px solid var(--ifm-color-primary);
54
- color: var(--ifm-color-primary);
57
+ .schemaTabActive {
58
+ background-color: var(--ifm-color-emphasis-100);
55
59
  }
56
60
 
57
61
  .schemaTabLabel {