docusaurus-theme-openapi-docs 4.6.0 → 4.7.0

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 (36) hide show
  1. package/lib/markdown/schema.js +5 -0
  2. package/lib/theme/ApiExplorer/Body/index.js +263 -128
  3. package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +13 -0
  4. package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.js +133 -0
  5. package/lib/theme/ApiExplorer/SchemaSelection/index.d.ts +2 -0
  6. package/lib/theme/ApiExplorer/SchemaSelection/index.js +36 -0
  7. package/lib/theme/ApiExplorer/SchemaSelection/slice.d.ts +37 -0
  8. package/lib/theme/ApiExplorer/SchemaSelection/slice.js +39 -0
  9. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  10. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  11. package/lib/theme/ApiItem/index.js +1 -0
  12. package/lib/theme/ApiItem/store.d.ts +6 -0
  13. package/lib/theme/ApiItem/store.js +6 -2
  14. package/lib/theme/RequestSchema/index.js +58 -52
  15. package/lib/theme/Schema/index.d.ts +6 -0
  16. package/lib/theme/Schema/index.js +135 -9
  17. package/lib/theme/SchemaTabs/index.d.ts +8 -1
  18. package/lib/theme/SchemaTabs/index.js +10 -1
  19. package/lib/theme/StatusCodes/index.d.ts +1 -1
  20. package/lib/theme/styles.scss +10 -0
  21. package/package.json +3 -3
  22. package/src/markdown/schema.ts +6 -0
  23. package/src/theme/ApiExplorer/Body/index.tsx +206 -122
  24. package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +155 -0
  25. package/{lib/types.js → src/theme/ApiExplorer/SchemaSelection/index.ts} +7 -2
  26. package/src/theme/ApiExplorer/SchemaSelection/slice.ts +46 -0
  27. package/src/theme/ApiItem/index.tsx +1 -0
  28. package/src/theme/ApiItem/store.ts +2 -0
  29. package/src/theme/RequestSchema/index.tsx +49 -39
  30. package/src/theme/Schema/index.tsx +184 -27
  31. package/src/theme/SchemaTabs/index.tsx +15 -4
  32. package/src/theme/StatusCodes/index.tsx +1 -2
  33. package/src/theme/styles.scss +10 -0
  34. package/tsconfig.tsbuildinfo +1 -1
  35. package/lib/types.d.ts +0 -54
  36. /package/src/{types.ts → types.d.ts} +0 -0
@@ -0,0 +1,37 @@
1
+ import { PayloadAction } from "@reduxjs/toolkit";
2
+ export interface SchemaSelectionState {
3
+ /**
4
+ * Maps schema path (e.g., "requestBody", "requestBody.anyOf.0.layer3")
5
+ * to the selected anyOf/oneOf option index
6
+ */
7
+ selections: {
8
+ [schemaPath: string]: number;
9
+ };
10
+ }
11
+ export declare const slice: import("@reduxjs/toolkit").Slice<SchemaSelectionState, {
12
+ /**
13
+ * Set the selected index for a specific schema path
14
+ */
15
+ setSchemaSelection: (state: {
16
+ selections: {
17
+ [x: string]: number;
18
+ };
19
+ }, action: PayloadAction<{
20
+ path: string;
21
+ index: number;
22
+ }>) => void;
23
+ /**
24
+ * Clear all schema selections (useful when navigating to a new API endpoint)
25
+ */
26
+ clearSchemaSelections: (state: {
27
+ selections: {
28
+ [x: string]: number;
29
+ };
30
+ }) => void;
31
+ }, "schemaSelection", "schemaSelection", import("@reduxjs/toolkit").SliceSelectors<SchemaSelectionState>>;
32
+ export declare const setSchemaSelection: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
33
+ path: string;
34
+ index: number;
35
+ }, "schemaSelection/setSchemaSelection">, clearSchemaSelections: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"schemaSelection/clearSchemaSelections">;
36
+ declare const _default: import("redux").Reducer<SchemaSelectionState>;
37
+ export default _default;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var _a;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.clearSchemaSelections =
11
+ exports.setSchemaSelection =
12
+ exports.slice =
13
+ void 0;
14
+ const toolkit_1 = require("@reduxjs/toolkit");
15
+ const initialState = {
16
+ selections: {},
17
+ };
18
+ exports.slice = (0, toolkit_1.createSlice)({
19
+ name: "schemaSelection",
20
+ initialState,
21
+ reducers: {
22
+ /**
23
+ * Set the selected index for a specific schema path
24
+ */
25
+ setSchemaSelection: (state, action) => {
26
+ state.selections[action.payload.path] = action.payload.index;
27
+ },
28
+ /**
29
+ * Clear all schema selections (useful when navigating to a new API endpoint)
30
+ */
31
+ clearSchemaSelections: (state) => {
32
+ state.selections = {};
33
+ },
34
+ },
35
+ });
36
+ ((_a = exports.slice.actions),
37
+ (exports.setSchemaSelection = _a.setSchemaSelection),
38
+ (exports.clearSchemaSelections = _a.clearSchemaSelections));
39
+ exports.default = exports.slice.reducer;
@@ -8,6 +8,7 @@ export declare function createPersistenceMiddleware(options: ThemeConfig["api"])
8
8
  body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
9
9
  params: import("./ParamOptions/slice").State;
10
10
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
11
+ schemaSelection: import("./SchemaSelection").SchemaSelectionState;
11
12
  }, import("redux-thunk").ThunkDispatch<{
12
13
  accept: import("./Accept/slice").State;
13
14
  contentType: import("./ContentType/slice").State;
@@ -16,4 +17,5 @@ export declare function createPersistenceMiddleware(options: ThemeConfig["api"])
16
17
  body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
17
18
  params: import("./ParamOptions/slice").State;
18
19
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
20
+ schemaSelection: import("./SchemaSelection").SchemaSelectionState;
19
21
  }, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").UnknownAction>>;
@@ -8,5 +8,6 @@ export declare const useTypedDispatch: () => import("redux-thunk").ThunkDispatch
8
8
  body: import("../ApiExplorer/Body/slice").FormBody | import("../ApiExplorer/Body/slice").RawBody | import("../ApiExplorer/Body/slice").EmptyBody;
9
9
  params: import("../ApiExplorer/ParamOptions/slice").State;
10
10
  auth: import("../ApiExplorer/Authorization/slice").AuthState;
11
+ schemaSelection: import("../ApiExplorer/SchemaSelection").SchemaSelectionState;
11
12
  }, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").UnknownAction>;
12
13
  export declare const useTypedSelector: TypedUseSelectorHook<RootState>;
@@ -133,6 +133,7 @@ function ApiItem(props) {
133
133
  body: { type: "empty" },
134
134
  params,
135
135
  auth,
136
+ schemaSelection: { selections: {} },
136
137
  },
137
138
  [persistenceMiddleware]
138
139
  );
@@ -6,6 +6,7 @@ declare const rootReducer: import("redux").Reducer<{
6
6
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
7
7
  params: import("@theme/ApiExplorer/ParamOptions/slice").State;
8
8
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
9
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState;
9
10
  }, import("redux").UnknownAction, Partial<{
10
11
  accept: import("@theme/ApiExplorer/Accept/slice").State | undefined;
11
12
  contentType: import("@theme/ApiExplorer/ContentType/slice").State | undefined;
@@ -14,6 +15,7 @@ declare const rootReducer: import("redux").Reducer<{
14
15
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody | undefined;
15
16
  params: import("@theme/ApiExplorer/ParamOptions/slice").State | undefined;
16
17
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState | undefined;
18
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState | undefined;
17
19
  }>>;
18
20
  export type RootState = ReturnType<typeof rootReducer>;
19
21
  export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
@@ -24,6 +26,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
24
26
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
25
27
  params: import("@theme/ApiExplorer/ParamOptions/slice").State;
26
28
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
29
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState;
27
30
  }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
28
31
  dispatch: import("redux-thunk").ThunkDispatch<{
29
32
  accept: import("@theme/ApiExplorer/Accept/slice").State;
@@ -33,6 +36,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
33
36
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
34
37
  params: import("@theme/ApiExplorer/ParamOptions/slice").State;
35
38
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
39
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState;
36
40
  }, undefined, import("redux").UnknownAction>;
37
41
  }>, import("redux").StoreEnhancer]>>;
38
42
  export declare const createStoreWithoutState: (preloadedState: {}, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
@@ -43,6 +47,7 @@ export declare const createStoreWithoutState: (preloadedState: {}, middlewares:
43
47
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
44
48
  params: import("@theme/ApiExplorer/ParamOptions/slice").State;
45
49
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
50
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState;
46
51
  }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
47
52
  dispatch: import("redux-thunk").ThunkDispatch<{
48
53
  accept: import("@theme/ApiExplorer/Accept/slice").State;
@@ -52,6 +57,7 @@ export declare const createStoreWithoutState: (preloadedState: {}, middlewares:
52
57
  body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
53
58
  params: import("@theme/ApiExplorer/ParamOptions/slice").State;
54
59
  auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
60
+ schemaSelection: import("@theme/ApiExplorer/SchemaSelection/slice").SchemaSelectionState;
55
61
  }, undefined, import("redux").UnknownAction>;
56
62
  }>, import("redux").StoreEnhancer]>>;
57
63
  export type AppDispatch = ReturnType<typeof createStoreWithState>["dispatch"];
@@ -25,15 +25,19 @@ const slice_5 = __importDefault(
25
25
  require("@theme/ApiExplorer/ParamOptions/slice")
26
26
  );
27
27
  const slice_6 = __importDefault(require("@theme/ApiExplorer/Response/slice"));
28
- const slice_7 = __importDefault(require("@theme/ApiExplorer/Server/slice"));
28
+ const slice_7 = __importDefault(
29
+ require("@theme/ApiExplorer/SchemaSelection/slice")
30
+ );
31
+ const slice_8 = __importDefault(require("@theme/ApiExplorer/Server/slice"));
29
32
  const rootReducer = (0, toolkit_1.combineReducers)({
30
33
  accept: slice_1.default,
31
34
  contentType: slice_4.default,
32
35
  response: slice_6.default,
33
- server: slice_7.default,
36
+ server: slice_8.default,
34
37
  body: slice_3.default,
35
38
  params: slice_5.default,
36
39
  auth: slice_2.default,
40
+ schemaSelection: slice_7.default,
37
41
  });
38
42
  const createStoreWithState = (preloadedState, middlewares) =>
39
43
  (0, toolkit_1.configureStore)({
@@ -34,7 +34,7 @@ const RequestSchemaComponent = ({ title, body, style }) => {
34
34
  if (mimeTypes.length > 1) {
35
35
  return react_1.default.createElement(
36
36
  MimeTabs_1.default,
37
- { className: "openapi-tabs__mime", schemaType: "request" },
37
+ { className: "openapi-tabs__mime", schemaType: "request", lazy: true },
38
38
  mimeTypes.map((mimeType) => {
39
39
  const firstBody = body.content[mimeType].schema;
40
40
  if (
@@ -50,62 +50,67 @@ const RequestSchemaComponent = ({ title, body, style }) => {
50
50
  TabItem_1.default,
51
51
  { key: mimeType, label: mimeType, value: mimeType },
52
52
  react_1.default.createElement(
53
- Details_1.default,
54
- {
55
- className: "openapi-markdown__details mime",
56
- "data-collapsed": false,
57
- open: true,
58
- style: style,
59
- summary: react_1.default.createElement(
60
- react_1.default.Fragment,
61
- null,
62
- react_1.default.createElement(
63
- "summary",
53
+ "div",
54
+ { style: { marginTop: "1rem" } },
55
+ react_1.default.createElement(
56
+ Details_1.default,
57
+ {
58
+ className: "openapi-markdown__details mime",
59
+ "data-collapsed": false,
60
+ open: true,
61
+ style: style,
62
+ summary: react_1.default.createElement(
63
+ react_1.default.Fragment,
64
64
  null,
65
65
  react_1.default.createElement(
66
- "h3",
67
- {
68
- className:
69
- "openapi-markdown__details-summary-header-body",
70
- },
71
- (0, Translate_1.translate)({
72
- id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
73
- message: title,
74
- }),
75
- body.required === true &&
76
- react_1.default.createElement(
77
- "span",
78
- { className: "openapi-schema__required" },
79
- (0, Translate_1.translate)({
80
- id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
81
- message: "required",
82
- })
83
- )
66
+ "summary",
67
+ null,
68
+ react_1.default.createElement(
69
+ "h3",
70
+ {
71
+ className:
72
+ "openapi-markdown__details-summary-header-body",
73
+ },
74
+ (0, Translate_1.translate)({
75
+ id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
76
+ message: title,
77
+ }),
78
+ body.required === true &&
79
+ react_1.default.createElement(
80
+ "span",
81
+ { className: "openapi-schema__required" },
82
+ (0, Translate_1.translate)({
83
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
84
+ message: "required",
85
+ })
86
+ )
87
+ )
84
88
  )
85
- )
86
- ),
87
- },
88
- react_1.default.createElement(
89
- "div",
90
- { style: { textAlign: "left", marginLeft: "1rem" } },
91
- body.description &&
92
- react_1.default.createElement(
93
- "div",
94
- { style: { marginTop: "1rem", marginBottom: "1rem" } },
89
+ ),
90
+ },
91
+ react_1.default.createElement(
92
+ "div",
93
+ { style: { textAlign: "left", marginLeft: "1rem" } },
94
+ body.description &&
95
95
  react_1.default.createElement(
96
- Markdown_1.default,
97
- null,
98
- body.description
96
+ "div",
97
+ { style: { marginTop: "1rem", marginBottom: "1rem" } },
98
+ react_1.default.createElement(
99
+ Markdown_1.default,
100
+ null,
101
+ body.description
102
+ )
99
103
  )
100
- )
101
- ),
102
- react_1.default.createElement(
103
- "ul",
104
- { style: { marginLeft: "1rem" } },
105
- react_1.default.createElement(Schema_1.default, {
106
- schema: firstBody,
107
- schemaType: "request",
108
- })
104
+ ),
105
+ react_1.default.createElement(
106
+ "ul",
107
+ { style: { marginLeft: "1rem" } },
108
+ react_1.default.createElement(Schema_1.default, {
109
+ schema: firstBody,
110
+ schemaType: "request",
111
+ schemaPath: "requestBody",
112
+ })
113
+ )
109
114
  )
110
115
  )
111
116
  )
@@ -184,6 +189,7 @@ const RequestSchemaComponent = ({ title, body, style }) => {
184
189
  react_1.default.createElement(Schema_1.default, {
185
190
  schema: firstBody,
186
191
  schemaType: "request",
192
+ schemaPath: "requestBody",
187
193
  })
188
194
  )
189
195
  )
@@ -3,6 +3,12 @@ import { SchemaObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
3
3
  interface SchemaProps {
4
4
  schema: SchemaObject;
5
5
  schemaType: "request" | "response";
6
+ /**
7
+ * Optional path identifier for tracking anyOf/oneOf selections.
8
+ * When provided, tab selections will be dispatched to Redux state
9
+ * to enable dynamic body example updates.
10
+ */
11
+ schemaPath?: string;
6
12
  }
7
13
  declare const SchemaNode: React.FC<SchemaProps>;
8
14
  export default SchemaNode;