docusaurus-theme-openapi-docs 4.6.0 → 4.7.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 (64) hide show
  1. package/lib/markdown/schema.js +5 -0
  2. package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
  3. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +1 -1
  4. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +1 -1
  5. package/lib/theme/ApiExplorer/Body/index.d.ts +1 -1
  6. package/lib/theme/ApiExplorer/Body/index.js +264 -129
  7. package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +13 -0
  8. package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.js +133 -0
  9. package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
  10. package/lib/theme/ApiExplorer/Request/index.d.ts +1 -1
  11. package/lib/theme/ApiExplorer/Response/index.d.ts +1 -1
  12. package/lib/theme/ApiExplorer/SchemaSelection/index.d.ts +2 -0
  13. package/lib/theme/ApiExplorer/SchemaSelection/index.js +36 -0
  14. package/lib/theme/ApiExplorer/SchemaSelection/slice.d.ts +37 -0
  15. package/lib/theme/ApiExplorer/SchemaSelection/slice.js +39 -0
  16. package/lib/theme/ApiExplorer/SecuritySchemes/index.js +2 -2
  17. package/lib/theme/ApiExplorer/Server/slice.d.ts +1 -1
  18. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  19. package/lib/theme/ApiExplorer/index.d.ts +1 -1
  20. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  21. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  22. package/lib/theme/ApiItem/index.js +1 -0
  23. package/lib/theme/ApiItem/store.d.ts +6 -0
  24. package/lib/theme/ApiItem/store.js +6 -2
  25. package/lib/theme/ParamsDetails/index.js +2 -2
  26. package/lib/theme/RequestSchema/index.d.ts +1 -1
  27. package/lib/theme/RequestSchema/index.js +60 -54
  28. package/lib/theme/ResponseSchema/index.d.ts +1 -1
  29. package/lib/theme/Schema/index.d.ts +7 -1
  30. package/lib/theme/Schema/index.js +135 -9
  31. package/lib/theme/SchemaTabs/index.d.ts +8 -1
  32. package/lib/theme/SchemaTabs/index.js +10 -1
  33. package/lib/theme/StatusCodes/index.d.ts +1 -1
  34. package/lib/theme/styles.scss +10 -0
  35. package/package.json +3 -3
  36. package/src/markdown/schema.ts +6 -0
  37. package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
  38. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +2 -0
  39. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +4 -2
  40. package/src/theme/ApiExplorer/Body/index.tsx +208 -125
  41. package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +155 -0
  42. package/src/theme/ApiExplorer/FormItem/index.tsx +0 -1
  43. package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
  44. package/src/theme/ApiExplorer/Request/index.tsx +2 -2
  45. package/src/theme/ApiExplorer/Response/index.tsx +2 -3
  46. package/{lib/types.js → src/theme/ApiExplorer/SchemaSelection/index.ts} +7 -2
  47. package/src/theme/ApiExplorer/SchemaSelection/slice.ts +46 -0
  48. package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +2 -3
  49. package/src/theme/ApiExplorer/Server/slice.ts +1 -1
  50. package/src/theme/ApiExplorer/buildPostmanRequest.ts +1 -1
  51. package/src/theme/ApiExplorer/index.tsx +1 -1
  52. package/src/theme/ApiItem/index.tsx +2 -1
  53. package/src/theme/ApiItem/store.ts +2 -0
  54. package/src/theme/ParamsDetails/index.tsx +2 -3
  55. package/src/theme/RequestSchema/index.tsx +52 -43
  56. package/src/theme/ResponseSchema/index.tsx +1 -1
  57. package/src/theme/Schema/index.tsx +186 -29
  58. package/src/theme/SchemaTabs/index.tsx +15 -4
  59. package/src/theme/StatusCodes/index.tsx +1 -2
  60. package/src/theme/styles.scss +10 -0
  61. package/src/types.d.ts +36 -0
  62. package/tsconfig.tsbuildinfo +1 -1
  63. package/lib/types.d.ts +0 -54
  64. package/src/types.ts +0 -80
@@ -7,11 +7,10 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
- import { translate } from "@docusaurus/Translate";
11
- import { OPENAPI_SECURITY_SCHEMES } from "@theme/translationIds";
12
-
13
10
  import Link from "@docusaurus/Link";
11
+ import { translate } from "@docusaurus/Translate";
14
12
  import { useTypedSelector } from "@theme/ApiItem/hooks";
13
+ import { OPENAPI_SECURITY_SCHEMES } from "@theme/translationIds";
15
14
 
16
15
  function SecuritySchemes(props: any) {
17
16
  const options = useTypedSelector((state: any) => state.auth.options);
@@ -6,7 +6,7 @@
6
6
  * ========================================================================== */
7
7
 
8
8
  import { createSlice, PayloadAction } from "@reduxjs/toolkit";
9
- import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
9
+ import type { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
10
10
  // TODO: we might want to export this
11
11
 
12
12
  export interface State {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { AuthState, Scheme } from "@theme/ApiExplorer/Authorization/slice";
9
9
  import { Body, Content } from "@theme/ApiExplorer/Body/slice";
10
- import {
10
+ import type {
11
11
  ParameterObject,
12
12
  ServerObject,
13
13
  } from "docusaurus-plugin-openapi-docs/src/openapi/types";
@@ -12,7 +12,7 @@ import CodeSnippets from "@theme/ApiExplorer/CodeSnippets";
12
12
  import Request from "@theme/ApiExplorer/Request";
13
13
  import Response from "@theme/ApiExplorer/Response";
14
14
  import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";
15
- import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
15
+ import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
16
16
  import * as sdk from "postman-collection";
17
17
 
18
18
  function ApiExplorer({
@@ -22,7 +22,7 @@ import type { Props } from "@theme/DocItem";
22
22
  import DocItemMetadata from "@theme/DocItem/Metadata";
23
23
  import SkeletonLoader from "@theme/SkeletonLoader";
24
24
  import clsx from "clsx";
25
- import {
25
+ import type {
26
26
  ParameterObject,
27
27
  ServerObject,
28
28
  } from "docusaurus-plugin-openapi-docs/src/openapi/types";
@@ -158,6 +158,7 @@ export default function ApiItem(props: Props): JSX.Element {
158
158
  body: { type: "empty" },
159
159
  params,
160
160
  auth,
161
+ schemaSelection: { selections: {} },
161
162
  },
162
163
  [persistenceMiddleware]
163
164
  );
@@ -12,6 +12,7 @@ import body from "@theme/ApiExplorer/Body/slice";
12
12
  import contentType from "@theme/ApiExplorer/ContentType/slice";
13
13
  import params from "@theme/ApiExplorer/ParamOptions/slice";
14
14
  import response from "@theme/ApiExplorer/Response/slice";
15
+ import schemaSelection from "@theme/ApiExplorer/SchemaSelection/slice";
15
16
  import server from "@theme/ApiExplorer/Server/slice";
16
17
 
17
18
  const rootReducer = combineReducers({
@@ -22,6 +23,7 @@ const rootReducer = combineReducers({
22
23
  body,
23
24
  params,
24
25
  auth,
26
+ schemaSelection,
25
27
  });
26
28
 
27
29
  export type RootState = ReturnType<typeof rootReducer>;
@@ -7,13 +7,12 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
- import { translate } from "@docusaurus/Translate";
11
- import { OPENAPI_PARAMS_DETAILS } from "@theme/translationIds";
12
-
13
10
  import BrowserOnly from "@docusaurus/BrowserOnly";
11
+ import { translate } from "@docusaurus/Translate";
14
12
  import Details from "@theme/Details";
15
13
  import ParamsItem from "@theme/ParamsItem";
16
14
  import SkeletonLoader from "@theme/SkeletonLoader";
15
+ import { OPENAPI_PARAMS_DETAILS } from "@theme/translationIds";
17
16
 
18
17
  interface Props {
19
18
  parameters: any[];
@@ -7,17 +7,16 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
- import { translate } from "@docusaurus/Translate";
11
- import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
12
-
13
10
  import BrowserOnly from "@docusaurus/BrowserOnly";
11
+ import { translate } from "@docusaurus/Translate";
14
12
  import Details from "@theme/Details";
15
13
  import Markdown from "@theme/Markdown";
16
14
  import MimeTabs from "@theme/MimeTabs"; // Assume these components exist
17
15
  import SchemaNode from "@theme/Schema";
18
16
  import SkeletonLoader from "@theme/SkeletonLoader";
19
17
  import TabItem from "@theme/TabItem";
20
- import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
18
+ import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
19
+ import type { MediaTypeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
21
20
 
22
21
  interface Props {
23
22
  style?: React.CSSProperties;
@@ -45,7 +44,7 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
45
44
 
46
45
  if (mimeTypes.length > 1) {
47
46
  return (
48
- <MimeTabs className="openapi-tabs__mime" schemaType="request">
47
+ <MimeTabs className="openapi-tabs__mime" schemaType="request" lazy>
49
48
  {mimeTypes.map((mimeType) => {
50
49
  const firstBody = body.content![mimeType].schema;
51
50
  if (
@@ -58,43 +57,49 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
58
57
  return (
59
58
  // @ts-ignore
60
59
  <TabItem key={mimeType} label={mimeType} value={mimeType}>
61
- <Details
62
- className="openapi-markdown__details mime"
63
- data-collapsed={false}
64
- open={true}
65
- style={style}
66
- summary={
67
- <>
68
- <summary>
69
- <h3 className="openapi-markdown__details-summary-header-body">
70
- {translate({
71
- id: OPENAPI_REQUEST.BODY_TITLE,
72
- message: title,
73
- })}
74
- {body.required === true && (
75
- <span className="openapi-schema__required">
76
- {translate({
77
- id: OPENAPI_SCHEMA_ITEM.REQUIRED,
78
- message: "required",
79
- })}
80
- </span>
81
- )}
82
- </h3>
83
- </summary>
84
- </>
85
- }
86
- >
87
- <div style={{ textAlign: "left", marginLeft: "1rem" }}>
88
- {body.description && (
89
- <div style={{ marginTop: "1rem", marginBottom: "1rem" }}>
90
- <Markdown>{body.description}</Markdown>
91
- </div>
92
- )}
93
- </div>
94
- <ul style={{ marginLeft: "1rem" }}>
95
- <SchemaNode schema={firstBody} schemaType="request" />
96
- </ul>
97
- </Details>
60
+ <div style={{ marginTop: "1rem" }}>
61
+ <Details
62
+ className="openapi-markdown__details mime"
63
+ data-collapsed={false}
64
+ open={true}
65
+ style={style}
66
+ summary={
67
+ <>
68
+ <summary>
69
+ <h3 className="openapi-markdown__details-summary-header-body">
70
+ {translate({
71
+ id: OPENAPI_REQUEST.BODY_TITLE,
72
+ message: title,
73
+ })}
74
+ {body.required === true && (
75
+ <span className="openapi-schema__required">
76
+ {translate({
77
+ id: OPENAPI_SCHEMA_ITEM.REQUIRED,
78
+ message: "required",
79
+ })}
80
+ </span>
81
+ )}
82
+ </h3>
83
+ </summary>
84
+ </>
85
+ }
86
+ >
87
+ <div style={{ textAlign: "left", marginLeft: "1rem" }}>
88
+ {body.description && (
89
+ <div style={{ marginTop: "1rem", marginBottom: "1rem" }}>
90
+ <Markdown>{body.description}</Markdown>
91
+ </div>
92
+ )}
93
+ </div>
94
+ <ul style={{ marginLeft: "1rem" }}>
95
+ <SchemaNode
96
+ schema={firstBody}
97
+ schemaType="request"
98
+ schemaPath="requestBody"
99
+ />
100
+ </ul>
101
+ </Details>
102
+ </div>
98
103
  </TabItem>
99
104
  );
100
105
  })}
@@ -151,7 +156,11 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
151
156
  )}
152
157
  </div>
153
158
  <ul style={{ marginLeft: "1rem" }}>
154
- <SchemaNode schema={firstBody} schemaType="request" />
159
+ <SchemaNode
160
+ schema={firstBody}
161
+ schemaType="request"
162
+ schemaPath="requestBody"
163
+ />
155
164
  </ul>
156
165
  </Details>
157
166
  </TabItem>
@@ -22,7 +22,7 @@ import SchemaTabs from "@theme/SchemaTabs";
22
22
  import SkeletonLoader from "@theme/SkeletonLoader";
23
23
  import TabItem from "@theme/TabItem";
24
24
  import { OPENAPI_SCHEMA, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
25
- import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
25
+ import type { MediaTypeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
26
26
 
27
27
  interface Props {
28
28
  style?: React.CSSProperties;