docusaurus-theme-openapi-docs 0.0.0-985 → 0.0.0-987

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.
@@ -215,9 +215,16 @@ function Body({
215
215
  }
216
216
  if (examples) {
217
217
  for (const [key, example] of Object.entries(examples)) {
218
+ let body = example.value;
219
+ try {
220
+ // If the value is already valid JSON we shouldn't double encode the value
221
+ JSON.parse(example.value);
222
+ } catch (e) {
223
+ body = JSON.stringify(example.value, null, 2);
224
+ }
218
225
  examplesBodies.push({
219
226
  label: key,
220
- body: JSON.stringify(example.value, null, 2),
227
+ body,
221
228
  summary: example.summary,
222
229
  });
223
230
  }
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-985",
4
+ "version": "0.0.0-987",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -36,7 +36,7 @@
36
36
  "@types/lodash": "^4.14.176",
37
37
  "@types/pako": "^2.0.3",
38
38
  "concurrently": "^5.2.0",
39
- "docusaurus-plugin-openapi-docs": "0.0.0-985",
39
+ "docusaurus-plugin-openapi-docs": "0.0.0-987",
40
40
  "docusaurus-plugin-sass": "^0.2.3",
41
41
  "eslint-plugin-prettier": "^5.0.1"
42
42
  },
@@ -79,5 +79,5 @@
79
79
  "engines": {
80
80
  "node": ">=14"
81
81
  },
82
- "gitHead": "9bdb2f50d0a01aa03ed4b3e5ba4a2ed67d55b02c"
82
+ "gitHead": "708ee88819e9fb9f34c14532367c48bac1b1df65"
83
83
  }
@@ -233,9 +233,18 @@ function Body({
233
233
  }
234
234
  if (examples) {
235
235
  for (const [key, example] of Object.entries(examples)) {
236
+ let body = example.value;
237
+ try {
238
+ // If the value is already valid JSON we shouldn't double encode the value
239
+ JSON.parse(example.value);
240
+ }
241
+ catch (e) {
242
+ body = JSON.stringify(example.value, null, 2);
243
+ }
244
+
236
245
  examplesBodies.push({
237
246
  label: key,
238
- body: JSON.stringify(example.value, null, 2),
247
+ body,
239
248
  summary: example.summary,
240
249
  });
241
250
  }