docusaurus-plugin-openapi-docs 0.0.0-402 → 0.0.0-403

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
@@ -246,7 +246,7 @@ yarn docusaurus gen-api-docs:version petstore:all
246
246
  Run the following to bootstrap a Docsaurus v2 site (classic theme) with `docusaurus-openapi-docs`:
247
247
 
248
248
  ```bash
249
- npx create-docusaurus@2.0.0-beta.21 my-website --package-manager yarn
249
+ npx create-docusaurus@2.0.0-rc.1 my-website --package-manager yarn
250
250
  ```
251
251
 
252
252
  > When prompted to select a template choose `Git repository`.
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-402",
4
+ "version": "0.0.0-403",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=14"
69
69
  },
70
- "gitHead": "0ad47c91138db5b9d06e329fe459b3a04c51c54d"
70
+ "gitHead": "e23091951747b00753116a1ba3b1ea6a6d7c2080"
71
71
  }
@@ -1 +0,0 @@
1
- export declare function createAnyOneOf(anyOneOf: any[], type: string): string | undefined;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- /* ============================================================================
3
- * Copyright (c) Palo Alto Networks
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- * ========================================================================== */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createAnyOneOf = void 0;
10
- const createSchemaDetails_1 = require("./createSchemaDetails");
11
- const utils_1 = require("./utils");
12
- function createAnyOneOf(anyOneOf, type) {
13
- if (anyOneOf === undefined) {
14
- return undefined;
15
- }
16
- if (anyOneOf.length === 0) {
17
- return undefined;
18
- }
19
- return (0, utils_1.create)("div", {
20
- children: [
21
- (0, utils_1.create)("span", {
22
- className: "badge badge--info",
23
- children: type,
24
- }),
25
- (0, utils_1.create)("SchemaTabs", {
26
- children: anyOneOf.map((schema, index) => {
27
- const label = schema.title ? schema.title : `MOD${index + 1}`;
28
- if (schema.properties !== undefined) {
29
- return (0, utils_1.create)("TabItem", {
30
- label: label,
31
- value: `${index}-properties`,
32
- children: [(0, createSchemaDetails_1.createNodes)(schema)],
33
- });
34
- }
35
- if (schema.allOf !== undefined) {
36
- return (0, utils_1.create)("TabItem", {
37
- label: label,
38
- value: `${index}-allOf`,
39
- children: [(0, createSchemaDetails_1.createNodes)(schema)],
40
- });
41
- }
42
- if (schema.items !== undefined) {
43
- if (schema.items.properties !== undefined) {
44
- return (0, utils_1.create)("TabItem", {
45
- label: label,
46
- value: `${index}-item-properties`,
47
- children: [(0, createSchemaDetails_1.createNodes)(schema.items)],
48
- });
49
- }
50
- }
51
- return undefined;
52
- }),
53
- }),
54
- ],
55
- });
56
- }
57
- exports.createAnyOneOf = createAnyOneOf;
@@ -1,3 +0,0 @@
1
- import { OpenAPISpec } from "./types";
2
- export declare function loadAndBundleSpec(specUrlOrObject: object | string, parseJsonRefs: boolean | undefined): Promise<OpenAPISpec>;
3
- export declare function convertSwagger2OpenAPI(spec: any): Promise<OpenAPISpec>;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- /* ============================================================================
3
- * Copyright (c) Palo Alto Networks
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- * ========================================================================== */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.convertSwagger2OpenAPI = exports.loadAndBundleSpec = void 0;
13
- // @ts-nocheck
14
- const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
15
- const bundle_1 = require("@redocly/openapi-core/lib/bundle");
16
- const config_1 = require("@redocly/openapi-core/lib/config/config");
17
- const chalk_1 = __importDefault(require("chalk"));
18
- const swagger2openapi_1 = require("swagger2openapi");
19
- async function resolveJsonRefs(specUrlOrObject) {
20
- var _a, _b;
21
- try {
22
- let schema = await json_schema_ref_parser_1.default.dereference(specUrlOrObject, {
23
- continueOnError: true,
24
- resolve: {
25
- http: {
26
- timeout: 15000, // 15 sec timeout
27
- },
28
- },
29
- dereference: {
30
- circular: "ignore",
31
- },
32
- });
33
- return schema;
34
- }
35
- catch (err) {
36
- console.error(chalk_1.default.yellow((_b = (_a = err.errors[0]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : err));
37
- return;
38
- }
39
- }
40
- async function loadAndBundleSpec(specUrlOrObject, parseJsonRefs) {
41
- const config = new config_1.Config({});
42
- const bundleOpts = {
43
- config,
44
- base: process.cwd(),
45
- };
46
- if (typeof specUrlOrObject === "object" && specUrlOrObject !== null) {
47
- bundleOpts["doc"] = {
48
- source: { absoluteRef: "" },
49
- parsed: specUrlOrObject,
50
- };
51
- }
52
- else {
53
- bundleOpts["ref"] = specUrlOrObject;
54
- }
55
- // Force dereference ?
56
- // bundleOpts["dereference"] = true;
57
- const { bundle: { parsed }, } = await (0, bundle_1.bundle)(bundleOpts);
58
- if (parseJsonRefs) {
59
- const resolved = await resolveJsonRefs(parsed);
60
- return typeof resolved === Object
61
- ? resolved.swagger !== undefined
62
- ? convertSwagger2OpenAPI(resolved)
63
- : resolved
64
- : parsed;
65
- }
66
- return parsed.swagger !== undefined ? convertSwagger2OpenAPI(parsed) : parsed;
67
- }
68
- exports.loadAndBundleSpec = loadAndBundleSpec;
69
- function convertSwagger2OpenAPI(spec) {
70
- console.warn("[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0");
71
- return new Promise((resolve, reject) => (0, swagger2openapi_1.convertObj)(spec, { patch: true, warnOnly: true, text: "{}", anchors: true }, (err, res) => {
72
- // TODO: log any warnings
73
- if (err) {
74
- return reject(err);
75
- }
76
- resolve(res && res.openapi);
77
- }));
78
- }
79
- exports.convertSwagger2OpenAPI = convertSwagger2OpenAPI;