docusaurus-plugin-openapi-docs 0.0.0-1047 → 0.0.0-1054

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/README.md CHANGED
@@ -127,6 +127,7 @@ import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs";
127
127
  petstore: {
128
128
  specPath: "examples/petstore.yaml",
129
129
  outputDir: "docs/petstore",
130
+ maskCredentials: false, // Disable credential masking in code snippets
130
131
  sidebarOptions: {
131
132
  groupPathsBy: "tag",
132
133
  },
@@ -155,25 +156,26 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
155
156
 
156
157
  `config` can be configured with the following options:
157
158
 
158
- | Name | Type | Default | Description |
159
- | -------------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
160
- | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
161
- | `outputDir` | `string` | `null` | Desired output path for generated MDX and sidebar files. |
162
- | `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
163
- | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
164
- | `infoTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **info** pages only. |
165
- | `tagTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **tag** pages only. |
166
- | `schemaTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **schema** pages only. |
167
- | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
168
- | `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the “Send API Request” button in the API demo panel. |
169
- | `showExtensions` | `boolean` | `null` | _Optional:_ If set to `true`, renders operation‑level vendor‑extensions in descriptions. |
170
- | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
171
- | `version` | `string` | `null` | _Optional:_ Version assigned to a single or micro‑spec API specified in `specPath`. |
172
- | `label` | `string` | `null` | _Optional:_ Version label used when generating the versionselector dropdown menu. |
173
- | `baseUrl` | `string` | `null` | _Optional:_ Base URL for versioned docs in the version‑selector dropdown. |
174
- | `versions` | `object` | `null` | _Optional:_ Options for versioning configuration. See below for a list of supported options. |
175
- | `markdownGenerators` | `object` | `null` | _Optional:_ Customize MDX content via generator functions. See below for a list of supported options. |
176
- | `showSchemas` | `boolean` | `null` | _Optional:_ If set to `true`, generates standalone schema pages and adds them to the sidebar. |
159
+ | Name | Type | Default | Description |
160
+ | -------------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
161
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
162
+ | `outputDir` | `string` | `null` | Desired output path for generated MDX and sidebar files. |
163
+ | `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
164
+ | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
165
+ | `infoTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **info** pages only. |
166
+ | `tagTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **tag** pages only. |
167
+ | `schemaTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **schema** pages only. |
168
+ | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
169
+ | `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the “Send API Request” button in the API demo panel. |
170
+ | `showExtensions` | `boolean` | `null` | _Optional:_ If set to `true`, renders operation‑level vendor‑extensions in descriptions. |
171
+ | `maskCredentials` | `boolean` | `true` | _Optional:_ If set to `false`, disables credential masking in generated code snippets. By default, credentials are masked for security. |
172
+ | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
173
+ | `version` | `string` | `null` | _Optional:_ Version assigned to a single or microspec API specified in `specPath`. |
174
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating the version‑selector dropdown menu. |
175
+ | `baseUrl` | `string` | `null` | _Optional:_ Base URL for versioned docs in the version‑selector dropdown. |
176
+ | `versions` | `object` | `null` | _Optional:_ Options for versioning configuration. See below for a list of supported options. |
177
+ | `markdownGenerators` | `object` | `null` | _Optional:_ Customize MDX content via generator functions. See below for a list of supported options. |
178
+ | `showSchemas` | `boolean` | `null` | _Optional:_ If set to `true`, generates standalone schema pages and adds them to the sidebar. |
177
179
 
178
180
  ### sidebarOptions
179
181
 
package/lib/index.js CHANGED
@@ -159,6 +159,9 @@ hide_send_button: true
159
159
  {{#frontMatter.show_extensions}}
160
160
  show_extensions: true
161
161
  {{/frontMatter.show_extensions}}
162
+ {{#frontMatter.mask_credentials_disabled}}
163
+ mask_credentials: false
164
+ {{/frontMatter.mask_credentials_disabled}}
162
165
  ---
163
166
 
164
167
  {{{markdown}}}
@@ -65,11 +65,16 @@ const loadAndResolveSpec_1 = require("./utils/loadAndResolveSpec");
65
65
  */
66
66
  function jsonToCollection(data) {
67
67
  return new Promise((resolve, reject) => {
68
+ var _a, _b;
68
69
  let schemaPack = new openapi_to_postmanv2_1.default.SchemaPack({ type: "json", data }, { schemaFaker: false });
69
70
  schemaPack.computedOptions.schemaFaker = false;
71
+ // Make sure the schema was properly validated or reject with error
72
+ if (!((_a = schemaPack.validationResult) === null || _a === void 0 ? void 0 : _a.result)) {
73
+ return reject((_b = schemaPack.validationResult) === null || _b === void 0 ? void 0 : _b.reason);
74
+ }
70
75
  schemaPack.convert((_err, conversionResult) => {
71
- if (!conversionResult.result) {
72
- return reject(conversionResult.reason);
76
+ if (_err || !conversionResult.result) {
77
+ return reject(_err || conversionResult.reason);
73
78
  }
74
79
  return resolve(new sdk.Collection(conversionResult.output[0].data));
75
80
  });
@@ -231,6 +236,9 @@ function createItems(openapiData, options, sidebarOptions) {
231
236
  ...((options === null || options === void 0 ? void 0 : options.showExtensions) && {
232
237
  show_extensions: options.showExtensions,
233
238
  }),
239
+ ...((options === null || options === void 0 ? void 0 : options.maskCredentials) === false && {
240
+ mask_credentials_disabled: true,
241
+ }),
234
242
  },
235
243
  api: {
236
244
  ...defaults,
@@ -350,6 +358,9 @@ function createItems(openapiData, options, sidebarOptions) {
350
358
  ...((options === null || options === void 0 ? void 0 : options.showExtensions) && {
351
359
  show_extensions: options.showExtensions,
352
360
  }),
361
+ ...((options === null || options === void 0 ? void 0 : options.maskCredentials) === false && {
362
+ mask_credentials_disabled: true,
363
+ }),
353
364
  },
354
365
  api: {
355
366
  ...defaults,
package/lib/options.js CHANGED
@@ -45,6 +45,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
45
45
  markdownGenerators: markdownGenerators,
46
46
  showSchemas: utils_validation_1.Joi.boolean(),
47
47
  disableCompression: utils_validation_1.Joi.boolean(),
48
+ maskCredentials: utils_validation_1.Joi.boolean(),
48
49
  version: utils_validation_1.Joi.string().when("versions", {
49
50
  is: utils_validation_1.Joi.exist(),
50
51
  then: utils_validation_1.Joi.required(),
package/lib/types.d.ts CHANGED
@@ -30,6 +30,7 @@ export interface APIOptions {
30
30
  markdownGenerators?: MarkdownGenerator;
31
31
  showSchemas?: boolean;
32
32
  disableCompression?: boolean;
33
+ maskCredentials?: boolean;
33
34
  }
34
35
  export interface MarkdownGenerator {
35
36
  createApiPageMD?: (pageData: ApiPageMetadata) => 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-1047",
4
+ "version": "0.0.0-1054",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=14"
67
67
  },
68
- "gitHead": "e380211820c49df8c5942e1452d6245df7409ef7"
68
+ "gitHead": "0e1499ea1924c58ddb345c8674ce22b9b3ec0922"
69
69
  }
package/src/index.ts CHANGED
@@ -234,6 +234,9 @@ hide_send_button: true
234
234
  {{#frontMatter.show_extensions}}
235
235
  show_extensions: true
236
236
  {{/frontMatter.show_extensions}}
237
+ {{#frontMatter.mask_credentials_disabled}}
238
+ mask_credentials: false
239
+ {{/frontMatter.mask_credentials_disabled}}
237
240
  ---
238
241
 
239
242
  {{{markdown}}}
@@ -43,9 +43,15 @@ function jsonToCollection(data: OpenApiObject): Promise<Collection> {
43
43
  { schemaFaker: false }
44
44
  );
45
45
  schemaPack.computedOptions.schemaFaker = false;
46
+
47
+ // Make sure the schema was properly validated or reject with error
48
+ if (!schemaPack.validationResult?.result) {
49
+ return reject(schemaPack.validationResult?.reason);
50
+ }
51
+
46
52
  schemaPack.convert((_err: any, conversionResult: any) => {
47
- if (!conversionResult.result) {
48
- return reject(conversionResult.reason);
53
+ if (_err || !conversionResult.result) {
54
+ return reject(_err || conversionResult.reason);
49
55
  }
50
56
  return resolve(new sdk.Collection(conversionResult.output[0].data));
51
57
  });
@@ -250,6 +256,9 @@ function createItems(
250
256
  ...(options?.showExtensions && {
251
257
  show_extensions: options.showExtensions,
252
258
  }),
259
+ ...(options?.maskCredentials === false && {
260
+ mask_credentials_disabled: true,
261
+ }),
253
262
  },
254
263
  api: {
255
264
  ...defaults,
@@ -403,6 +412,9 @@ function createItems(
403
412
  ...(options?.showExtensions && {
404
413
  show_extensions: options.showExtensions,
405
414
  }),
415
+ ...(options?.maskCredentials === false && {
416
+ mask_credentials_disabled: true,
417
+ }),
406
418
  },
407
419
  api: {
408
420
  ...defaults,
package/src/options.ts CHANGED
@@ -49,6 +49,7 @@ export const OptionsSchema = Joi.object({
49
49
  markdownGenerators: markdownGenerators,
50
50
  showSchemas: Joi.boolean(),
51
51
  disableCompression: Joi.boolean(),
52
+ maskCredentials: Joi.boolean(),
52
53
  version: Joi.string().when("versions", {
53
54
  is: Joi.exist(),
54
55
  then: Joi.required(),
package/src/types.ts CHANGED
@@ -52,6 +52,7 @@ export interface APIOptions {
52
52
  markdownGenerators?: MarkdownGenerator;
53
53
  showSchemas?: boolean;
54
54
  disableCompression?: boolean;
55
+ maskCredentials?: boolean;
55
56
  }
56
57
 
57
58
  export interface MarkdownGenerator {