docusaurus-theme-openapi-docs 0.0.0-1004 → 0.0.0-1006

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.
@@ -379,9 +379,8 @@ function buildPostmanRequest(
379
379
  }
380
380
  clonedPostman.url.host = [url];
381
381
  }
382
- setQueryParams(clonedPostman, queryParams);
383
- setPathParams(clonedPostman, pathParams);
384
- const cookie = buildCookie(cookieParams);
382
+ const enhancedQueryParams = [...queryParams];
383
+ const enhancedCookieParams = [...cookieParams];
385
384
  let otherHeaders = [];
386
385
  let selectedAuth = [];
387
386
  if (auth.selected !== undefined) {
@@ -434,23 +433,41 @@ function buildPostmanRequest(
434
433
  });
435
434
  continue;
436
435
  }
437
- // API Key
436
+ // API Key in header
438
437
  if (a.type === "apiKey" && a.in === "header") {
439
438
  const { apiKey } = auth.data[a.key];
440
- if (apiKey === undefined) {
441
- otherHeaders.push({
442
- key: a.name,
443
- value: `<${a.name ?? a.type}>`,
444
- });
445
- continue;
446
- }
447
439
  otherHeaders.push({
448
440
  key: a.name,
449
- value: apiKey,
441
+ value: apiKey || `<${a.name ?? a.type}>`,
442
+ });
443
+ continue;
444
+ }
445
+ // API Key in query
446
+ if (a.type === "apiKey" && a.in === "query") {
447
+ const { apiKey } = auth.data[a.key];
448
+ enhancedQueryParams.push({
449
+ name: a.name,
450
+ in: "query",
451
+ value: apiKey || `<${a.name ?? a.type}>`,
452
+ });
453
+ continue;
454
+ }
455
+ // API Key in cookie
456
+ if (a.type === "apiKey" && a.in === "cookie") {
457
+ const { apiKey } = auth.data[a.key];
458
+ enhancedCookieParams.push({
459
+ name: a.name,
460
+ in: "cookie",
461
+ value: apiKey || `<${a.name ?? a.type}>`,
450
462
  });
451
463
  continue;
452
464
  }
453
465
  }
466
+ // Use the enhanced params that might include API keys
467
+ setQueryParams(clonedPostman, enhancedQueryParams);
468
+ setPathParams(clonedPostman, pathParams);
469
+ // Use enhanced cookie params that might include API keys
470
+ const cookie = buildCookie(enhancedCookieParams);
454
471
  setHeaders(
455
472
  clonedPostman,
456
473
  contentType,
@@ -114,10 +114,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
114
114
  react_1.default.createElement(
115
115
  TabItem_1.default,
116
116
  { key: index, label: label, value: `${index}-item-properties` },
117
- (["string", "number", "integer", "boolean"].includes(
118
- anyOneSchema.type
119
- ) ||
120
- anyOneSchema.const) &&
117
+ (isPrimitive(anyOneSchema) || anyOneSchema.const) &&
121
118
  react_1.default.createElement(SchemaItem_1.default, {
122
119
  collapsible: false,
123
120
  name: undefined,
@@ -884,3 +881,13 @@ const SchemaNode = ({ schema, schemaType }) => {
884
881
  return renderChildren(schema, schemaType);
885
882
  };
886
883
  exports.default = SchemaNode;
884
+ const PRIMITIVE_TYPES = {
885
+ string: true,
886
+ number: true,
887
+ integer: true,
888
+ boolean: true,
889
+ null: true,
890
+ };
891
+ const isPrimitive = (schema) => {
892
+ return PRIMITIVE_TYPES[schema.type];
893
+ };
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-1004",
4
+ "version": "0.0.0-1006",
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-1004",
39
+ "docusaurus-plugin-openapi-docs": "0.0.0-1006",
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": "6c6f8eca76a5407f7896a4141ac9d104f75a5970"
82
+ "gitHead": "e73c0b0cead279cb3771b546adc1caebabf336ae"
83
83
  }
@@ -430,10 +430,9 @@ function buildPostmanRequest(
430
430
  clonedPostman.url.host = [url];
431
431
  }
432
432
 
433
- setQueryParams(clonedPostman, queryParams);
434
- setPathParams(clonedPostman, pathParams);
433
+ const enhancedQueryParams = [...queryParams];
434
+ const enhancedCookieParams = [...cookieParams];
435
435
 
436
- const cookie = buildCookie(cookieParams);
437
436
  let otherHeaders = [];
438
437
 
439
438
  let selectedAuth: Scheme[] = [];
@@ -491,24 +490,46 @@ function buildPostmanRequest(
491
490
  continue;
492
491
  }
493
492
 
494
- // API Key
493
+ // API Key in header
495
494
  if (a.type === "apiKey" && a.in === "header") {
496
495
  const { apiKey } = auth.data[a.key];
497
- if (apiKey === undefined) {
498
- otherHeaders.push({
499
- key: a.name,
500
- value: `<${a.name ?? a.type}>`,
501
- });
502
- continue;
503
- }
504
496
  otherHeaders.push({
505
497
  key: a.name,
506
- value: apiKey,
498
+ value: apiKey || `<${a.name ?? a.type}>`,
499
+ });
500
+ continue;
501
+ }
502
+
503
+ // API Key in query
504
+ if (a.type === "apiKey" && a.in === "query") {
505
+ const { apiKey } = auth.data[a.key];
506
+ enhancedQueryParams.push({
507
+ name: a.name,
508
+ in: "query",
509
+ value: apiKey || `<${a.name ?? a.type}>`,
510
+ });
511
+ continue;
512
+ }
513
+
514
+ // API Key in cookie
515
+ if (a.type === "apiKey" && a.in === "cookie") {
516
+ const { apiKey } = auth.data[a.key];
517
+ enhancedCookieParams.push({
518
+ name: a.name,
519
+ in: "cookie",
520
+ value: apiKey || `<${a.name ?? a.type}>`,
507
521
  });
508
522
  continue;
509
523
  }
510
524
  }
511
525
 
526
+ // Use the enhanced params that might include API keys
527
+ setQueryParams(clonedPostman, enhancedQueryParams);
528
+ setPathParams(clonedPostman, pathParams);
529
+
530
+ // Use enhanced cookie params that might include API keys
531
+ const cookie = buildCookie(enhancedCookieParams);
532
+
512
533
  setHeaders(
513
534
  clonedPostman,
514
535
  contentType,
@@ -21,7 +21,10 @@ import {
21
21
  getQualifierMessage,
22
22
  getSchemaName,
23
23
  } from "docusaurus-plugin-openapi-docs/lib/markdown/schema";
24
- import { SchemaObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
24
+ import {
25
+ SchemaObject,
26
+ SchemaType,
27
+ } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
25
28
  import isEmpty from "lodash/isEmpty";
26
29
 
27
30
  // eslint-disable-next-line import/no-extraneous-dependencies
@@ -122,10 +125,7 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
122
125
  value={`${index}-item-properties`}
123
126
  >
124
127
  {/* Handle primitive types directly */}
125
- {(["string", "number", "integer", "boolean"].includes(
126
- anyOneSchema.type
127
- ) ||
128
- anyOneSchema.const) && (
128
+ {(isPrimitive(anyOneSchema) || anyOneSchema.const) && (
129
129
  <SchemaItem
130
130
  collapsible={false}
131
131
  name={undefined}
@@ -938,3 +938,17 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
938
938
  };
939
939
 
940
940
  export default SchemaNode;
941
+
942
+ type PrimitiveSchemaType = Exclude<SchemaType, "object" | "array">;
943
+
944
+ const PRIMITIVE_TYPES: Record<PrimitiveSchemaType, true> = {
945
+ string: true,
946
+ number: true,
947
+ integer: true,
948
+ boolean: true,
949
+ null: true,
950
+ } as const;
951
+
952
+ const isPrimitive = (schema: SchemaObject) => {
953
+ return PRIMITIVE_TYPES[schema.type as PrimitiveSchemaType];
954
+ };