docusaurus-theme-openapi-docs 0.0.0-1267 → 0.0.0-1293

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.
@@ -101,9 +101,21 @@ function ApiItem(props) {
101
101
  api?.parameters?.forEach((param) => {
102
102
  const paramType = param.in;
103
103
  const paramsArray = params[paramType];
104
- const defaultValue = param.schema?.default;
104
+ const p = param;
105
+ // Prefill order: schema.default, then example sources. `default` is
106
+ // semantically a server-side fallback, so for required params authors
107
+ // typically rely on `example` / `examples`. See #544 and #1079.
108
+ const firstNamedExample =
109
+ p.examples && typeof p.examples === "object"
110
+ ? Object.values(p.examples)[0]?.value
111
+ : undefined;
112
+ const prefill =
113
+ p.schema?.default ??
114
+ p.example ??
115
+ p.schema?.example ??
116
+ firstNamedExample;
105
117
  const initialized =
106
- defaultValue !== undefined ? { ...param, value: defaultValue } : param;
118
+ prefill !== undefined ? { ...param, value: prefill } : param;
107
119
  paramsArray?.push(initialized);
108
120
  });
109
121
  const auth = (0, slice_1.createAuth)({
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-1267",
4
+ "version": "0.0.0-1293",
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-1267",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1293",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14"
84
84
  },
85
- "gitHead": "fae66624a389286ba5ccf067ff73ac435307cbb9"
85
+ "gitHead": "b0f99481fef92f91530e08164d5a98e3b4ddb65d"
86
86
  }
@@ -123,10 +123,22 @@ export default function ApiItem(props: Props): JSX.Element {
123
123
  (param: { in: "path" | "query" | "header" | "cookie" }) => {
124
124
  const paramType = param.in;
125
125
  const paramsArray: ParameterObject[] = params[paramType];
126
- const defaultValue = (param as any).schema?.default;
126
+ const p = param as any;
127
+ // Prefill order: schema.default, then example sources. `default` is
128
+ // semantically a server-side fallback, so for required params authors
129
+ // typically rely on `example` / `examples`. See #544 and #1079.
130
+ const firstNamedExample =
131
+ p.examples && typeof p.examples === "object"
132
+ ? (Object.values(p.examples)[0] as any)?.value
133
+ : undefined;
134
+ const prefill =
135
+ p.schema?.default ??
136
+ p.example ??
137
+ p.schema?.example ??
138
+ firstNamedExample;
127
139
  const initialized =
128
- defaultValue !== undefined
129
- ? ({ ...param, value: defaultValue } as unknown as ParameterObject)
140
+ prefill !== undefined
141
+ ? ({ ...param, value: prefill } as unknown as ParameterObject)
130
142
  : (param as ParameterObject);
131
143
  paramsArray?.push(initialized);
132
144
  }