diff --git a/src/utils/convertSpec.ts b/src/utils/convertSpec.ts index 6d7547c7..88ac0da5 100644 --- a/src/utils/convertSpec.ts +++ b/src/utils/convertSpec.ts @@ -1,24 +1,8 @@ import { convertObj } from 'swagger2openapi'; - -const swagger2OpenAPICommon = require('swagger2openapi/common'); import { OpenAPISpec } from '../types'; -// temporarily monkey-patch sha256 from swagger2openapi package with simpler hash function -// to not include 300KB crypto module polyfill into bundle -// TODO: remove when https://github.com/Mermade/swagger2openapi/pull/37 is merged -swagger2OpenAPICommon.sha256 = function(s) { - let hash = 0; - let chr; - if (s.length === 0) return hash; - for (let i = 0; i < s.length; i++) { - chr = s.charCodeAt(i); - hash = (hash << 5) - hash + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; -}; - export function convertSwagger2OpenAPI(spec: any): Promise { + console.warn('[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0'); return new Promise((resolve, reject) => convertObj(spec, {}, (err, res) => { // TODO: log any warnings diff --git a/webpack.config.js b/webpack.config.js index a8ada030..8408db84 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -42,7 +42,6 @@ module.exports = env => { node: { fs: 'empty', - crypto: 'empty', }, externals: {