docusaurus-plugin-openapi-docs 0.0.0-528 → 0.0.0-530

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.
package/lib/index.js CHANGED
@@ -87,8 +87,8 @@ function pluginOpenAPIDocs(context, options) {
87
87
  ? specPath
88
88
  : path_1.default.resolve(siteDir, specPath);
89
89
  try {
90
- const openapiFiles = await (0, openapi_1.readOpenapiFiles)(contentPath, options);
91
- const [loadedApi, tags] = await (0, openapi_1.processOpenapiFiles)(openapiFiles, sidebarOptions);
90
+ const openapiFiles = await (0, openapi_1.readOpenapiFiles)(contentPath);
91
+ const [loadedApi, tags] = await (0, openapi_1.processOpenapiFiles)(openapiFiles, options, sidebarOptions);
92
92
  if (!fs_1.default.existsSync(outputDir)) {
93
93
  try {
94
94
  fs_1.default.mkdirSync(outputDir, { recursive: true });
@@ -144,6 +144,9 @@ sidebar_class_name: "{{{api.method}}} api-method"
144
144
  info_path: {{{infoPath}}}
145
145
  {{/infoPath}}
146
146
  custom_edit_url: null
147
+ {{#frontMatter.proxy}}
148
+ proxy: {{{frontMatter.proxy}}}
149
+ {{/frontMatter.proxy}}
147
150
  ---
148
151
 
149
152
  {{{markdown}}}
@@ -480,6 +480,7 @@ function createEdges({ name, schema, required, discriminator, }) {
480
480
  collapsible: false,
481
481
  name,
482
482
  required: Array.isArray(required) ? required.includes(name) : required,
483
+ deprecated: mergedSchemas.deprecated,
483
484
  schemaDescription: mergedSchemas.description,
484
485
  schemaName: schemaName,
485
486
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
@@ -507,6 +508,7 @@ function createEdges({ name, schema, required, discriminator, }) {
507
508
  collapsible: false,
508
509
  name,
509
510
  required: Array.isArray(required) ? required.includes(name) : required,
511
+ deprecated: schema.deprecated,
510
512
  schemaDescription: schema.description,
511
513
  schemaName: schemaName,
512
514
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
@@ -479,6 +479,7 @@ function createEdges({ name, schema, required, discriminator, }) {
479
479
  collapsible: false,
480
480
  name,
481
481
  required: false,
482
+ deprecated: mergedSchemas.deprecated,
482
483
  schemaDescription: mergedSchemas.description,
483
484
  schemaName: schemaName,
484
485
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
@@ -506,6 +507,7 @@ function createEdges({ name, schema, required, discriminator, }) {
506
507
  collapsible: false,
507
508
  name,
508
509
  required: false,
510
+ deprecated: schema.deprecated,
509
511
  schemaDescription: schema.description,
510
512
  schemaName: schemaName,
511
513
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
@@ -76,7 +76,7 @@ const sampleRequestFromSchema = (schema = {}) => {
76
76
  const { mergedSchemas } = (0, createRequestSchema_1.mergeAllOf)(allOf);
77
77
  if (mergedSchemas.properties) {
78
78
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
79
- if (value.readOnly && value.readOnly === true) {
79
+ if ((value.readOnly && value.readOnly === true) || value.deprecated) {
80
80
  delete mergedSchemas.properties[key];
81
81
  }
82
82
  }
@@ -99,14 +99,16 @@ const sampleRequestFromSchema = (schema = {}) => {
99
99
  for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
100
100
  if (prop.properties) {
101
101
  for (const [key, value] of Object.entries(prop.properties)) {
102
- if (value.readOnly && value.readOnly === true) {
102
+ if ((value.readOnly && value.readOnly === true) ||
103
+ value.deprecated) {
103
104
  delete prop.properties[key];
104
105
  }
105
106
  }
106
107
  }
107
108
  if (prop.items && prop.items.properties) {
108
109
  for (const [key, value] of Object.entries(prop.items.properties)) {
109
- if (value.readOnly && value.readOnly === true) {
110
+ if ((value.readOnly && value.readOnly === true) ||
111
+ value.deprecated) {
110
112
  delete prop.items.properties[key];
111
113
  }
112
114
  }
@@ -137,7 +139,7 @@ const sampleRequestFromSchema = (schema = {}) => {
137
139
  }
138
140
  return normalizeArray(schema.enum)[0];
139
141
  }
140
- if (schema.readOnly && schema.readOnly === true) {
142
+ if ((schema.readOnly && schema.readOnly === true) || schema.deprecated) {
141
143
  return undefined;
142
144
  }
143
145
  return primitive(schema);
@@ -68,7 +68,8 @@ const sampleResponseFromSchema = (schema = {}) => {
68
68
  const { mergedSchemas } = (0, createResponseSchema_1.mergeAllOf)(allOf);
69
69
  if (mergedSchemas.properties) {
70
70
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
71
- if (value.writeOnly && value.writeOnly === true) {
71
+ if ((value.writeOnly && value.writeOnly === true) ||
72
+ value.deprecated) {
72
73
  delete mergedSchemas.properties[key];
73
74
  }
74
75
  }
@@ -99,14 +100,16 @@ const sampleResponseFromSchema = (schema = {}) => {
99
100
  for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
100
101
  if (prop.properties) {
101
102
  for (const [key, value] of Object.entries(prop.properties)) {
102
- if (value.writeOnly && value.writeOnly === true) {
103
+ if ((value.writeOnly && value.writeOnly === true) ||
104
+ value.deprecated) {
103
105
  delete prop.properties[key];
104
106
  }
105
107
  }
106
108
  }
107
109
  if (prop.items && prop.items.properties) {
108
110
  for (const [key, value] of Object.entries(prop.items.properties)) {
109
- if (value.writeOnly && value.writeOnly === true) {
111
+ if ((value.writeOnly && value.writeOnly === true) ||
112
+ value.deprecated) {
110
113
  delete prop.items.properties[key];
111
114
  }
112
115
  }
@@ -137,7 +140,7 @@ const sampleResponseFromSchema = (schema = {}) => {
137
140
  }
138
141
  return normalizeArray(schema.enum)[0];
139
142
  }
140
- if (schema.writeOnly && schema.writeOnly === true) {
143
+ if ((schema.writeOnly && schema.writeOnly === true) || schema.deprecated) {
141
144
  return undefined;
142
145
  }
143
146
  return primitive(schema);
@@ -5,8 +5,8 @@ interface OpenApiFiles {
5
5
  sourceDirName: string;
6
6
  data: OpenApiObject;
7
7
  }
8
- export declare function readOpenapiFiles(openapiPath: string, options: APIOptions): Promise<OpenApiFiles[]>;
9
- export declare function processOpenapiFiles(files: OpenApiFiles[], sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[][]]>;
10
- export declare function processOpenapiFile(openapiData: OpenApiObject, sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
8
+ export declare function readOpenapiFiles(openapiPath: string): Promise<OpenApiFiles[]>;
9
+ export declare function processOpenapiFiles(files: OpenApiFiles[], options: APIOptions, sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[][]]>;
10
+ export declare function processOpenapiFile(openapiData: OpenApiObject, options: APIOptions, sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
11
11
  export declare function getTagDisplayName(tagName: string, tags: TagObject[]): string;
12
12
  export {};
@@ -60,7 +60,7 @@ async function createPostmanCollection(openapiData) {
60
60
  }
61
61
  return await jsonToCollection(data);
62
62
  }
63
- function createItems(openapiData, sidebarOptions) {
63
+ function createItems(openapiData, options, sidebarOptions) {
64
64
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
65
65
  // TODO: Find a better way to handle this
66
66
  let items = [];
@@ -172,6 +172,7 @@ function createItems(openapiData, sidebarOptions) {
172
172
  .replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'")
173
173
  .replace(/\s+$/, "")
174
174
  : "",
175
+ ...((options === null || options === void 0 ? void 0 : options.proxy) && { proxy: options.proxy }),
175
176
  },
176
177
  api: {
177
178
  ...defaults,
@@ -249,7 +250,7 @@ function bindCollectionToApiItems(items, postmanCollection) {
249
250
  }
250
251
  });
251
252
  }
252
- async function readOpenapiFiles(openapiPath, options) {
253
+ async function readOpenapiFiles(openapiPath) {
253
254
  if (!(0, index_1.isURL)(openapiPath)) {
254
255
  const stat = await fs_extra_1.default.lstat(openapiPath);
255
256
  if (stat.isDirectory()) {
@@ -282,10 +283,10 @@ async function readOpenapiFiles(openapiPath, options) {
282
283
  ];
283
284
  }
284
285
  exports.readOpenapiFiles = readOpenapiFiles;
285
- async function processOpenapiFiles(files, sidebarOptions) {
286
+ async function processOpenapiFiles(files, options, sidebarOptions) {
286
287
  const promises = files.map(async (file) => {
287
288
  if (file.data !== undefined) {
288
- const processedFile = await processOpenapiFile(file.data, sidebarOptions);
289
+ const processedFile = await processOpenapiFile(file.data, options, sidebarOptions);
289
290
  const itemsObjectsArray = processedFile[0].map((item) => ({
290
291
  ...item,
291
292
  }));
@@ -316,9 +317,9 @@ async function processOpenapiFiles(files, sidebarOptions) {
316
317
  return [items, tags];
317
318
  }
318
319
  exports.processOpenapiFiles = processOpenapiFiles;
319
- async function processOpenapiFile(openapiData, sidebarOptions) {
320
+ async function processOpenapiFile(openapiData, options, sidebarOptions) {
320
321
  const postmanCollection = await createPostmanCollection(openapiData);
321
- const items = createItems(openapiData, sidebarOptions);
322
+ const items = createItems(openapiData, options, sidebarOptions);
322
323
  bindCollectionToApiItems(items, postmanCollection);
323
324
  let tags = [];
324
325
  if (openapiData.tags !== undefined) {
@@ -16,7 +16,7 @@ const _1 = require(".");
16
16
  describe("openapi", () => {
17
17
  describe("readOpenapiFiles", () => {
18
18
  it("readOpenapiFiles", async () => {
19
- const results = await (0, _1.readOpenapiFiles)((0, utils_1.posixPath)(path_1.default.join(__dirname, "__fixtures__/examples")), { specPath: "./", outputDir: "./" });
19
+ const results = await (0, _1.readOpenapiFiles)((0, utils_1.posixPath)(path_1.default.join(__dirname, "__fixtures__/examples")));
20
20
  const categoryMeta = results.find((x) => x.source.endsWith("_category_.json"));
21
21
  expect(categoryMeta).toBeFalsy();
22
22
  // console.log(results);
package/lib/options.js CHANGED
@@ -21,6 +21,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
21
21
  config: utils_validation_1.Joi.object()
22
22
  .pattern(/^/, utils_validation_1.Joi.object({
23
23
  specPath: utils_validation_1.Joi.string().required(),
24
+ proxy: utils_validation_1.Joi.string(),
24
25
  outputDir: utils_validation_1.Joi.string().required(),
25
26
  template: utils_validation_1.Joi.string(),
26
27
  downloadUrl: utils_validation_1.Joi.string(),
package/lib/types.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface APIOptions {
20
20
  versions?: {
21
21
  [key: string]: APIVersionOptions;
22
22
  };
23
+ proxy?: string;
23
24
  }
24
25
  export interface SidebarOptions {
25
26
  groupPathsBy?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "0.0.0-528",
4
+ "version": "0.0.0-530",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "1d7d37e6d7af896dd62cdca42bdd54aa4ed0a944"
71
+ "gitHead": "a31ab6ddf963c070ad5bcb15edaa6ef50e6cd3b7"
72
72
  }
package/src/index.ts CHANGED
@@ -106,9 +106,10 @@ export default function pluginOpenAPIDocs(
106
106
  : path.resolve(siteDir, specPath);
107
107
 
108
108
  try {
109
- const openapiFiles = await readOpenapiFiles(contentPath, options);
109
+ const openapiFiles = await readOpenapiFiles(contentPath);
110
110
  const [loadedApi, tags] = await processOpenapiFiles(
111
111
  openapiFiles,
112
+ options,
112
113
  sidebarOptions!
113
114
  );
114
115
  if (!fs.existsSync(outputDir)) {
@@ -183,6 +184,9 @@ sidebar_class_name: "{{{api.method}}} api-method"
183
184
  info_path: {{{infoPath}}}
184
185
  {{/infoPath}}
185
186
  custom_edit_url: null
187
+ {{#frontMatter.proxy}}
188
+ proxy: {{{frontMatter.proxy}}}
189
+ {{/frontMatter.proxy}}
186
190
  ---
187
191
 
188
192
  {{{markdown}}}
@@ -597,6 +597,7 @@ function createEdges({
597
597
  collapsible: false,
598
598
  name,
599
599
  required: Array.isArray(required) ? required.includes(name) : required,
600
+ deprecated: mergedSchemas.deprecated,
600
601
  schemaDescription: mergedSchemas.description,
601
602
  schemaName: schemaName,
602
603
  qualifierMessage: getQualifierMessage(schema),
@@ -630,6 +631,7 @@ function createEdges({
630
631
  collapsible: false,
631
632
  name,
632
633
  required: Array.isArray(required) ? required.includes(name) : required,
634
+ deprecated: schema.deprecated,
633
635
  schemaDescription: schema.description,
634
636
  schemaName: schemaName,
635
637
  qualifierMessage: getQualifierMessage(schema),
@@ -597,6 +597,7 @@ function createEdges({
597
597
  collapsible: false,
598
598
  name,
599
599
  required: false,
600
+ deprecated: mergedSchemas.deprecated,
600
601
  schemaDescription: mergedSchemas.description,
601
602
  schemaName: schemaName,
602
603
  qualifierMessage: getQualifierMessage(schema),
@@ -630,6 +631,7 @@ function createEdges({
630
631
  collapsible: false,
631
632
  name,
632
633
  required: false,
634
+ deprecated: schema.deprecated,
633
635
  schemaDescription: schema.description,
634
636
  schemaName: schemaName,
635
637
  qualifierMessage: getQualifierMessage(schema),
@@ -98,7 +98,7 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
98
98
  mergeAllOf(allOf);
99
99
  if (mergedSchemas.properties) {
100
100
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
101
- if (value.readOnly && value.readOnly === true) {
101
+ if ((value.readOnly && value.readOnly === true) || value.deprecated) {
102
102
  delete mergedSchemas.properties[key];
103
103
  }
104
104
  }
@@ -121,7 +121,10 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
121
121
  for (let [name, prop] of Object.entries(properties ?? {})) {
122
122
  if (prop.properties) {
123
123
  for (const [key, value] of Object.entries(prop.properties)) {
124
- if (value.readOnly && value.readOnly === true) {
124
+ if (
125
+ (value.readOnly && value.readOnly === true) ||
126
+ value.deprecated
127
+ ) {
125
128
  delete prop.properties[key];
126
129
  }
127
130
  }
@@ -129,7 +132,10 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
129
132
 
130
133
  if (prop.items && prop.items.properties) {
131
134
  for (const [key, value] of Object.entries(prop.items.properties)) {
132
- if (value.readOnly && value.readOnly === true) {
135
+ if (
136
+ (value.readOnly && value.readOnly === true) ||
137
+ value.deprecated
138
+ ) {
133
139
  delete prop.items.properties[key];
134
140
  }
135
141
  }
@@ -168,7 +174,7 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
168
174
  return normalizeArray(schema.enum)[0];
169
175
  }
170
176
 
171
- if (schema.readOnly && schema.readOnly === true) {
177
+ if ((schema.readOnly && schema.readOnly === true) || schema.deprecated) {
172
178
  return undefined;
173
179
  }
174
180
 
@@ -88,7 +88,10 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
88
88
  mergeAllOf(allOf);
89
89
  if (mergedSchemas.properties) {
90
90
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
91
- if (value.writeOnly && value.writeOnly === true) {
91
+ if (
92
+ (value.writeOnly && value.writeOnly === true) ||
93
+ value.deprecated
94
+ ) {
92
95
  delete mergedSchemas.properties[key];
93
96
  }
94
97
  }
@@ -121,7 +124,10 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
121
124
  for (let [name, prop] of Object.entries(properties ?? {})) {
122
125
  if (prop.properties) {
123
126
  for (const [key, value] of Object.entries(prop.properties)) {
124
- if (value.writeOnly && value.writeOnly === true) {
127
+ if (
128
+ (value.writeOnly && value.writeOnly === true) ||
129
+ value.deprecated
130
+ ) {
125
131
  delete prop.properties[key];
126
132
  }
127
133
  }
@@ -129,7 +135,10 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
129
135
 
130
136
  if (prop.items && prop.items.properties) {
131
137
  for (const [key, value] of Object.entries(prop.items.properties)) {
132
- if (value.writeOnly && value.writeOnly === true) {
138
+ if (
139
+ (value.writeOnly && value.writeOnly === true) ||
140
+ value.deprecated
141
+ ) {
133
142
  delete prop.items.properties[key];
134
143
  }
135
144
  }
@@ -168,7 +177,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
168
177
  return normalizeArray(schema.enum)[0];
169
178
  }
170
179
 
171
- if (schema.writeOnly && schema.writeOnly === true) {
180
+ if ((schema.writeOnly && schema.writeOnly === true) || schema.deprecated) {
172
181
  return undefined;
173
182
  }
174
183
 
@@ -17,8 +17,7 @@ describe("openapi", () => {
17
17
  describe("readOpenapiFiles", () => {
18
18
  it("readOpenapiFiles", async () => {
19
19
  const results = await readOpenapiFiles(
20
- posixPath(path.join(__dirname, "__fixtures__/examples")),
21
- { specPath: "./", outputDir: "./" }
20
+ posixPath(path.join(__dirname, "__fixtures__/examples"))
22
21
  );
23
22
  const categoryMeta = results.find((x) =>
24
23
  x.source.endsWith("_category_.json")
@@ -80,6 +80,7 @@ type PartialPage<T> = Omit<T, "permalink" | "source" | "sourceDirName">;
80
80
 
81
81
  function createItems(
82
82
  openapiData: OpenApiObject,
83
+ options: APIOptions,
83
84
  sidebarOptions: SidebarOptions
84
85
  ): ApiMetadata[] {
85
86
  // TODO: Find a better way to handle this
@@ -219,6 +220,7 @@ function createItems(
219
220
  .replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'")
220
221
  .replace(/\s+$/, "")
221
222
  : "",
223
+ ...(options?.proxy && { proxy: options.proxy }),
222
224
  },
223
225
  api: {
224
226
  ...defaults,
@@ -319,8 +321,7 @@ interface OpenApiFiles {
319
321
  }
320
322
 
321
323
  export async function readOpenapiFiles(
322
- openapiPath: string,
323
- options: APIOptions
324
+ openapiPath: string
324
325
  ): Promise<OpenApiFiles[]> {
325
326
  if (!isURL(openapiPath)) {
326
327
  const stat = await fs.lstat(openapiPath);
@@ -362,11 +363,16 @@ export async function readOpenapiFiles(
362
363
 
363
364
  export async function processOpenapiFiles(
364
365
  files: OpenApiFiles[],
366
+ options: APIOptions,
365
367
  sidebarOptions: SidebarOptions
366
368
  ): Promise<[ApiMetadata[], TagObject[][]]> {
367
369
  const promises = files.map(async (file) => {
368
370
  if (file.data !== undefined) {
369
- const processedFile = await processOpenapiFile(file.data, sidebarOptions);
371
+ const processedFile = await processOpenapiFile(
372
+ file.data,
373
+ options,
374
+ sidebarOptions
375
+ );
370
376
  const itemsObjectsArray = processedFile[0].map((item) => ({
371
377
  ...item,
372
378
  }));
@@ -403,10 +409,11 @@ export async function processOpenapiFiles(
403
409
 
404
410
  export async function processOpenapiFile(
405
411
  openapiData: OpenApiObject,
412
+ options: APIOptions,
406
413
  sidebarOptions: SidebarOptions
407
414
  ): Promise<[ApiMetadata[], TagObject[]]> {
408
415
  const postmanCollection = await createPostmanCollection(openapiData);
409
- const items = createItems(openapiData, sidebarOptions);
416
+ const items = createItems(openapiData, options, sidebarOptions);
410
417
 
411
418
  bindCollectionToApiItems(items, postmanCollection);
412
419
 
package/src/options.ts CHANGED
@@ -23,6 +23,7 @@ export const OptionsSchema = Joi.object({
23
23
  /^/,
24
24
  Joi.object({
25
25
  specPath: Joi.string().required(),
26
+ proxy: Joi.string(),
26
27
  outputDir: Joi.string().required(),
27
28
  template: Joi.string(),
28
29
  downloadUrl: Joi.string(),
package/src/types.ts CHANGED
@@ -40,6 +40,7 @@ export interface APIOptions {
40
40
  versions?: {
41
41
  [key: string]: APIVersionOptions;
42
42
  };
43
+ proxy?: string;
43
44
  }
44
45
 
45
46
  export interface SidebarOptions {