docusaurus-plugin-openapi-docs 0.0.0-737 → 0.0.0-739

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.
@@ -186,7 +186,7 @@ function createAdditionalProperties(schema: SchemaObject) {
186
186
  title ?? schemaName,
187
187
  additionalProperties,
188
188
  required,
189
- schema.nullable,
189
+ schema.nullable
190
190
  );
191
191
  }
192
192
 
@@ -202,7 +202,7 @@ function createAdditionalProperties(schema: SchemaObject) {
202
202
  if (additionalProperties !== undefined) {
203
203
  const type = schema.additionalProperties?.additionalProperties?.type;
204
204
  const schemaName = getSchemaName(
205
- schema.additionalProperties?.additionalProperties!,
205
+ schema.additionalProperties?.additionalProperties!
206
206
  );
207
207
  return create("SchemaItem", {
208
208
  name: "property name*",
@@ -234,7 +234,7 @@ function createAdditionalProperties(schema: SchemaObject) {
234
234
  required: Array.isArray(schema.required)
235
235
  ? schema.required.includes(key)
236
236
  : false,
237
- }),
237
+ })
238
238
  );
239
239
  }
240
240
 
@@ -333,7 +333,7 @@ function createItems(schema: SchemaObject) {
333
333
  required: Array.isArray(schema.required)
334
334
  ? schema.required.includes(key)
335
335
  : false,
336
- }),
336
+ })
337
337
  ),
338
338
  createClosingArrayBracket(),
339
339
  ].flat();
@@ -347,7 +347,7 @@ function createDetailsNode(
347
347
  schemaName: string,
348
348
  schema: SchemaObject,
349
349
  required: string[] | boolean,
350
- nullable: boolean | unknown,
350
+ nullable: boolean | unknown
351
351
  ): any {
352
352
  return create("SchemaItem", {
353
353
  collapsible: true,
@@ -381,7 +381,7 @@ function createDetailsNode(
381
381
  create("span", {
382
382
  className: "openapi-schema__divider",
383
383
  }),
384
- ],
384
+ ]
385
385
  ),
386
386
  guard(nullable, () => [
387
387
  create("span", {
@@ -398,7 +398,7 @@ function createDetailsNode(
398
398
  className: "openapi-schema__required",
399
399
  children: "required",
400
400
  }),
401
- ],
401
+ ]
402
402
  ),
403
403
  guard(schema.deprecated, () => [
404
404
  create("span", {
@@ -417,13 +417,13 @@ function createDetailsNode(
417
417
  create("div", {
418
418
  style: { marginTop: ".5rem", marginBottom: ".5rem" },
419
419
  children: createDescription(message),
420
- }),
420
+ })
421
421
  ),
422
422
  guard(schema.description, (description) =>
423
423
  create("div", {
424
424
  style: { marginTop: ".5rem", marginBottom: ".5rem" },
425
425
  children: createDescription(description),
426
- }),
426
+ })
427
427
  ),
428
428
  createNodes(schema, SCHEMA_TYPE),
429
429
  ],
@@ -442,7 +442,7 @@ function createAnyOneOfProperty(
442
442
  schemaName: string,
443
443
  schema: SchemaObject,
444
444
  required: string[] | boolean,
445
- nullable: boolean | unknown,
445
+ nullable: boolean | unknown
446
446
  ): any {
447
447
  return create("SchemaItem", {
448
448
  collapsible: true,
@@ -469,7 +469,7 @@ function createAnyOneOfProperty(
469
469
  },
470
470
  children: " nullable",
471
471
  }),
472
- ],
472
+ ]
473
473
  ),
474
474
  guard(
475
475
  Array.isArray(required)
@@ -483,7 +483,7 @@ function createAnyOneOfProperty(
483
483
  },
484
484
  children: " required",
485
485
  }),
486
- ],
486
+ ]
487
487
  ),
488
488
  ],
489
489
  }),
@@ -494,13 +494,13 @@ function createAnyOneOfProperty(
494
494
  create("div", {
495
495
  style: { marginTop: ".5rem", marginBottom: ".5rem" },
496
496
  children: createDescription(message),
497
- }),
497
+ })
498
498
  ),
499
499
  guard(schema.description, (description) =>
500
500
  create("div", {
501
501
  style: { marginTop: ".5rem", marginBottom: ".5rem" },
502
502
  children: createDescription(description),
503
- }),
503
+ })
504
504
  ),
505
505
  ],
506
506
  }),
@@ -520,7 +520,7 @@ function createPropertyDiscriminator(
520
520
  schemaName: string,
521
521
  schema: SchemaObject,
522
522
  discriminator: any,
523
- required: string[] | boolean,
523
+ required: string[] | boolean
524
524
  ): any {
525
525
  if (schema === undefined) {
526
526
  return undefined;
@@ -545,7 +545,7 @@ function createPropertyDiscriminator(
545
545
  create("span", {
546
546
  className: "openapi-schema__name",
547
547
  children: ` ${schemaName}`,
548
- }),
548
+ })
549
549
  ),
550
550
  guard(required, () => [
551
551
  create("span", {
@@ -561,7 +561,7 @@ function createPropertyDiscriminator(
561
561
  paddingLeft: "1rem",
562
562
  },
563
563
  children: createDescription(message),
564
- }),
564
+ })
565
565
  ),
566
566
  guard(schema.description, (description) =>
567
567
  create("div", {
@@ -569,7 +569,7 @@ function createPropertyDiscriminator(
569
569
  paddingLeft: "1rem",
570
570
  },
571
571
  children: createDescription(description),
572
- }),
572
+ })
573
573
  ),
574
574
  create("DiscriminatorTabs", {
575
575
  className: "openapi-tabs__discriminator",
@@ -623,7 +623,7 @@ function createEdges({
623
623
  "string",
624
624
  schema,
625
625
  discriminator,
626
- required,
626
+ required
627
627
  );
628
628
  }
629
629
 
@@ -633,13 +633,13 @@ function createEdges({
633
633
  schemaName,
634
634
  schema,
635
635
  required,
636
- schema.nullable,
636
+ schema.nullable
637
637
  );
638
638
  }
639
639
 
640
640
  if (schema.allOf !== undefined) {
641
641
  const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
642
- schema.allOf,
642
+ schema.allOf
643
643
  );
644
644
 
645
645
  if (SCHEMA_TYPE === "request") {
@@ -664,7 +664,7 @@ function createEdges({
664
664
  mergedSchemaName,
665
665
  mergedSchemas,
666
666
  required,
667
- schema.nullable,
667
+ schema.nullable
668
668
  );
669
669
  }
670
670
 
@@ -674,7 +674,7 @@ function createEdges({
674
674
  mergedSchemaName,
675
675
  mergedSchemas,
676
676
  required,
677
- schema.nullable,
677
+ schema.nullable
678
678
  );
679
679
  }
680
680
 
@@ -684,7 +684,7 @@ function createEdges({
684
684
  mergedSchemaName,
685
685
  mergedSchemas,
686
686
  required,
687
- schema.nullable,
687
+ schema.nullable
688
688
  );
689
689
  }
690
690
 
@@ -695,7 +695,7 @@ function createEdges({
695
695
  mergedSchemaName,
696
696
  mergedSchemas,
697
697
  required,
698
- schema.nullable,
698
+ schema.nullable
699
699
  );
700
700
  }
701
701
 
@@ -715,7 +715,7 @@ function createEdges({
715
715
  schemaName,
716
716
  schema,
717
717
  required,
718
- schema.nullable,
718
+ schema.nullable
719
719
  );
720
720
  }
721
721
 
@@ -725,7 +725,7 @@ function createEdges({
725
725
  schemaName,
726
726
  schema,
727
727
  required,
728
- schema.nullable,
728
+ schema.nullable
729
729
  );
730
730
  }
731
731
 
@@ -736,7 +736,7 @@ function createEdges({
736
736
  schemaName,
737
737
  schema,
738
738
  required,
739
- schema.nullable,
739
+ schema.nullable
740
740
  );
741
741
  }
742
742
 
@@ -746,7 +746,7 @@ function createEdges({
746
746
  schemaName,
747
747
  schema,
748
748
  required,
749
- schema.nullable,
749
+ schema.nullable
750
750
  );
751
751
  }
752
752
 
@@ -766,7 +766,7 @@ function createEdges({
766
766
  */
767
767
  export function createNodes(
768
768
  schema: SchemaObject,
769
- schemaType: "request" | "response",
769
+ schemaType: "request" | "response"
770
770
  ): any {
771
771
  SCHEMA_TYPE = schemaType;
772
772
  if (SCHEMA_TYPE === "request") {
@@ -843,7 +843,7 @@ export function createNodes(
843
843
  paddingTop: "1rem",
844
844
  },
845
845
  children: createDescription(message),
846
- }),
846
+ })
847
847
  ),
848
848
  ],
849
849
  });
@@ -864,7 +864,7 @@ export function createNodes(
864
864
  paddingTop: "1rem",
865
865
  },
866
866
  children: createDescription(message),
867
- }),
867
+ })
868
868
  ),
869
869
  ],
870
870
  });
@@ -95,22 +95,22 @@ function createResponseHeaders(responseHeaders: any) {
95
95
  guard(example, () => `Example: ${example}`),
96
96
  createDescription(description),
97
97
  ],
98
- }),
98
+ })
99
99
  ),
100
100
  ],
101
101
  }),
102
102
  ],
103
103
  });
104
- },
104
+ }
105
105
  ),
106
106
  ],
107
- }),
107
+ })
108
108
  );
109
109
  }
110
110
 
111
111
  export function createResponseExamples(
112
112
  responseExamples: any,
113
- mimeType: string,
113
+ mimeType: string
114
114
  ) {
115
115
  let language = "shell";
116
116
  if (mimeType.endsWith("json")) {
@@ -153,7 +153,7 @@ export function createResponseExamples(
153
153
  }),
154
154
  ],
155
155
  });
156
- },
156
+ }
157
157
  );
158
158
  }
159
159
 
@@ -285,7 +285,7 @@ export function createStatusCodes({ label, id, responses }: Props) {
285
285
  responseHeaders &&
286
286
  createDetails({
287
287
  className: "openapi-markdown__details",
288
- "data-collaposed": true,
288
+ "data-collapsed": true,
289
289
  open: false,
290
290
  style: { textAlign: "left", marginBottom: "1rem" },
291
291
  children: [
@@ -49,7 +49,7 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
49
49
 
50
50
  export function getSchemaName(
51
51
  schema: SchemaObject,
52
- circular?: boolean,
52
+ circular?: boolean
53
53
  ): string {
54
54
  if (schema.items) {
55
55
  return prettyName(schema.items, circular) + "[]";
@@ -83,7 +83,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
83
83
  if (schema.items && schema.items.enum) {
84
84
  if (schema.items.enum) {
85
85
  qualifierGroups.push(
86
- `[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`,
86
+ `[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
87
87
  );
88
88
  }
89
89
  }
@@ -154,7 +154,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
154
154
 
155
155
  if (schema.pattern) {
156
156
  qualifierGroups.push(
157
- `Value must match regular expression \`${schema.pattern}\``,
157
+ `Value must match regular expression \`${schema.pattern}\``
158
158
  );
159
159
  }
160
160
 
@@ -22,7 +22,7 @@ export function create(tag: string, props: Props): string {
22
22
 
23
23
  export function guard<T>(
24
24
  value: T | undefined,
25
- cb: (value: T) => Children,
25
+ cb: (value: T) => Children
26
26
  ): string {
27
27
  if (!!value || value === 0) {
28
28
  const children = cb(value);
@@ -67,7 +67,7 @@ function sampleRequestFromProp(name: string, prop: any, obj: any): any {
67
67
  obj[name] = sampleRequestFromSchema(prop.anyOf[0]);
68
68
  } else if (prop.allOf) {
69
69
  const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
70
- prop.allOf,
70
+ prop.allOf
71
71
  );
72
72
  sampleRequestFromProp(name, mergedSchemas, obj);
73
73
  } else {
@@ -150,7 +150,7 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
150
150
 
151
151
  if (prop.items && prop.items.properties) {
152
152
  for (const [key, value] of Object.entries(
153
- prop.items.properties,
153
+ prop.items.properties
154
154
  ) as any) {
155
155
  if (
156
156
  (value.readOnly && value.readOnly === true) ||
@@ -204,10 +204,7 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
204
204
  return primitive(schemaCopy);
205
205
  } catch (err) {
206
206
  console.error(
207
- chalk.yellow(
208
- "WARNING: failed to create example from schema object:",
209
- err,
210
- ),
207
+ chalk.yellow("WARNING: failed to create example from schema object:", err)
211
208
  );
212
209
  return;
213
210
  }
@@ -67,7 +67,7 @@ function sampleResponseFromProp(name: string, prop: any, obj: any): any {
67
67
  obj[name] = sampleResponseFromSchema(prop.anyOf[0]);
68
68
  } else if (prop.allOf) {
69
69
  const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
70
- prop.allOf,
70
+ prop.allOf
71
71
  );
72
72
  sampleResponseFromProp(name, mergedSchemas, obj);
73
73
  } else {
@@ -153,7 +153,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
153
153
 
154
154
  if (prop.items && prop.items.properties) {
155
155
  for (const [key, value] of Object.entries(
156
- prop.items.properties,
156
+ prop.items.properties
157
157
  ) as any) {
158
158
  if (
159
159
  (value.writeOnly && value.writeOnly === true) ||
@@ -207,10 +207,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
207
207
  return primitive(schemaCopy);
208
208
  } catch (err) {
209
209
  console.error(
210
- chalk.yellow(
211
- "WARNING: failed to create example from schema object:",
212
- err,
213
- ),
210
+ chalk.yellow("WARNING: failed to create example from schema object:", err)
214
211
  );
215
212
  return;
216
213
  }
@@ -18,10 +18,10 @@ describe("openapi", () => {
18
18
  describe("readOpenapiFiles", () => {
19
19
  it("readOpenapiFiles", async () => {
20
20
  const results = await readOpenapiFiles(
21
- posixPath(path.join(__dirname, "__fixtures__/examples")),
21
+ posixPath(path.join(__dirname, "__fixtures__/examples"))
22
22
  );
23
23
  const categoryMeta = results.find((x) =>
24
- x.source.endsWith("_category_.json"),
24
+ x.source.endsWith("_category_.json")
25
25
  );
26
26
  expect(categoryMeta).toBeFalsy();
27
27
  // console.log(results);
@@ -33,7 +33,7 @@ describe("openapi", () => {
33
33
  expect(yaml?.data["x-tagGroups"]).toBeDefined();
34
34
 
35
35
  expect(
36
- yaml?.data.components?.schemas?.HelloString["x-tags"],
36
+ yaml?.data.components?.schemas?.HelloString["x-tags"]
37
37
  ).toBeDefined();
38
38
  });
39
39
  });
@@ -39,7 +39,7 @@ function jsonToCollection(data: OpenApiObject): Promise<Collection> {
39
39
  return new Promise((resolve, reject) => {
40
40
  let schemaPack = new Converter.SchemaPack(
41
41
  { type: "json", data },
42
- { schemaFaker: false },
42
+ { schemaFaker: false }
43
43
  );
44
44
  schemaPack.computedOptions.schemaFaker = false;
45
45
  schemaPack.convert((_err: any, conversionResult: any) => {
@@ -55,7 +55,7 @@ function jsonToCollection(data: OpenApiObject): Promise<Collection> {
55
55
  * Creates a Postman Collection object from an OpenAPI definition.
56
56
  */
57
57
  async function createPostmanCollection(
58
- openapiData: OpenApiObject,
58
+ openapiData: OpenApiObject
59
59
  ): Promise<Collection> {
60
60
  // Create copy of openapiData
61
61
  const data = cloneDeep(openapiData) as OpenApiObject;
@@ -82,7 +82,7 @@ type PartialPage<T> = Omit<T, "permalink" | "source" | "sourceDirName">;
82
82
  function createItems(
83
83
  openapiData: OpenApiObject,
84
84
  options: APIOptions,
85
- sidebarOptions: SidebarOptions,
85
+ sidebarOptions: SidebarOptions
86
86
  ): ApiMetadata[] {
87
87
  // TODO: Find a better way to handle this
88
88
  let items: PartialPage<ApiMetadata>[] = [];
@@ -106,7 +106,7 @@ function createItems(
106
106
  description: openapiData.info.description
107
107
  ? openapiData.info.description.replace(
108
108
  /((?:^|[^\\])(?:\\{2})*)"/g,
109
- "$1'",
109
+ "$1'"
110
110
  )
111
111
  : "",
112
112
  frontMatter: {
@@ -210,7 +210,7 @@ function createItems(
210
210
  defaults.parameters = unionBy(
211
211
  operationObject.parameters,
212
212
  parameters,
213
- "name",
213
+ "name"
214
214
  );
215
215
  } else {
216
216
  defaults.parameters = parameters;
@@ -232,7 +232,7 @@ function createItems(
232
232
  description: operationObject.description
233
233
  ? operationObject.description.replace(
234
234
  /((?:^|[^\\])(?:\\{2})*)"/g,
235
- "$1'",
235
+ "$1'"
236
236
  )
237
237
  : "",
238
238
  frontMatter: {
@@ -269,7 +269,7 @@ function createItems(
269
269
 
270
270
  // Gather x-webhooks endpoints
271
271
  for (let [path, pathObject] of Object.entries(
272
- openapiData["x-webhooks"] ?? {},
272
+ openapiData["x-webhooks"] ?? {}
273
273
  )) {
274
274
  path = "webhook";
275
275
  const { $ref, description, parameters, servers, summary, ...rest } =
@@ -354,7 +354,7 @@ function createItems(
354
354
  defaults.parameters = unionBy(
355
355
  operationObject.parameters,
356
356
  parameters,
357
- "name",
357
+ "name"
358
358
  );
359
359
  } else {
360
360
  defaults.parameters = parameters;
@@ -376,7 +376,7 @@ function createItems(
376
376
  description: operationObject.description
377
377
  ? operationObject.description.replace(
378
378
  /((?:^|[^\\])(?:\\{2})*)"/g,
379
- "$1'",
379
+ "$1'"
380
380
  )
381
381
  : "",
382
382
  frontMatter: {
@@ -418,7 +418,7 @@ function createItems(
418
418
  ) {
419
419
  // Gather schemas
420
420
  for (let [schema, schemaObject] of Object.entries(
421
- openapiData?.components?.schemas ?? {},
421
+ openapiData?.components?.schemas ?? {}
422
422
  )) {
423
423
  if (options?.showSchemas === true || schemaObject["x-tags"]) {
424
424
  const baseIdSpaces =
@@ -442,7 +442,7 @@ function createItems(
442
442
  description: schemaObject.description
443
443
  ? schemaObject.description.replace(
444
444
  /((?:^|[^\\])(?:\\{2})*)"/g,
445
- "$1'",
445
+ "$1'"
446
446
  )
447
447
  : "",
448
448
  frontMatter: {
@@ -471,7 +471,7 @@ function createItems(
471
471
  const operationTags = uniq(
472
472
  apiItems
473
473
  .flatMap((item) => item.api.tags)
474
- .filter((item): item is string => !!item),
474
+ .filter((item): item is string => !!item)
475
475
  );
476
476
 
477
477
  // eslint-disable-next-line array-callback-return
@@ -481,7 +481,7 @@ function createItems(
481
481
  .map((tag) => {
482
482
  const description = getTagDisplayName(
483
483
  tag.name!,
484
- openapiData.tags ?? [],
484
+ openapiData.tags ?? []
485
485
  );
486
486
  const tagId = kebabCase(tag.name);
487
487
  const splitDescription = description.match(/[^\r\n]+/g);
@@ -514,7 +514,7 @@ function createItems(
514
514
  */
515
515
  function bindCollectionToApiItems(
516
516
  items: ApiMetadata[],
517
- postmanCollection: sdk.Collection,
517
+ postmanCollection: sdk.Collection
518
518
  ) {
519
519
  postmanCollection.forEachItem((item: any) => {
520
520
  const method = item.request.method.toLowerCase();
@@ -545,7 +545,7 @@ interface OpenApiFiles {
545
545
  }
546
546
 
547
547
  export async function readOpenapiFiles(
548
- openapiPath: string,
548
+ openapiPath: string
549
549
  ): Promise<OpenApiFiles[]> {
550
550
  if (!isURL(openapiPath)) {
551
551
  const stat = await fs.lstat(openapiPath);
@@ -562,19 +562,19 @@ export async function readOpenapiFiles(
562
562
  // TODO: make a function for this
563
563
  const fullPath = posixPath(path.join(openapiPath, source));
564
564
  const data = (await loadAndResolveSpec(
565
- fullPath,
565
+ fullPath
566
566
  )) as unknown as OpenApiObject;
567
567
  return {
568
568
  source: fullPath, // This will be aliased in process.
569
569
  sourceDirName: path.dirname(source),
570
570
  data,
571
571
  };
572
- }),
572
+ })
573
573
  );
574
574
  }
575
575
  }
576
576
  const data = (await loadAndResolveSpec(
577
- openapiPath,
577
+ openapiPath
578
578
  )) as unknown as OpenApiObject;
579
579
  return [
580
580
  {
@@ -588,14 +588,14 @@ export async function readOpenapiFiles(
588
588
  export async function processOpenapiFiles(
589
589
  files: OpenApiFiles[],
590
590
  options: APIOptions,
591
- sidebarOptions: SidebarOptions,
591
+ sidebarOptions: SidebarOptions
592
592
  ): Promise<[ApiMetadata[], TagObject[][], TagGroupObject[]]> {
593
593
  const promises = files.map(async (file) => {
594
594
  if (file.data !== undefined) {
595
595
  const processedFile = await processOpenapiFile(
596
596
  file.data,
597
597
  options,
598
- sidebarOptions,
598
+ sidebarOptions
599
599
  );
600
600
  const itemsObjectsArray = processedFile[0].map((item) => ({
601
601
  ...item,
@@ -606,8 +606,8 @@ export async function processOpenapiFiles(
606
606
  }
607
607
  console.warn(
608
608
  chalk.yellow(
609
- `WARNING: the following OpenAPI spec returned undefined: ${file.source}`,
610
- ),
609
+ `WARNING: the following OpenAPI spec returned undefined: ${file.source}`
610
+ )
611
611
  );
612
612
  return [];
613
613
  });
@@ -651,7 +651,7 @@ export async function processOpenapiFiles(
651
651
  export async function processOpenapiFile(
652
652
  openapiData: OpenApiObject,
653
653
  options: APIOptions,
654
- sidebarOptions: SidebarOptions,
654
+ sidebarOptions: SidebarOptions
655
655
  ): Promise<[ApiMetadata[], TagObject[], TagGroupObject[]]> {
656
656
  const postmanCollection = await createPostmanCollection(openapiData);
657
657
  const items = createItems(openapiData, options, sidebarOptions);
@@ -61,7 +61,7 @@ function serializer(replacer: any, cycleReplacer: any) {
61
61
 
62
62
  export function convertSwagger2OpenAPI(spec: object) {
63
63
  console.warn(
64
- "[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0",
64
+ "[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0"
65
65
  );
66
66
  return new Promise((resolve, reject) =>
67
67
  convertObj(
@@ -79,8 +79,8 @@ export function convertSwagger2OpenAPI(spec: object) {
79
79
  return reject(err);
80
80
  }
81
81
  resolve(res && res.openapi);
82
- },
83
- ),
82
+ }
83
+ )
84
84
  );
85
85
  }
86
86