Remove crypto hack after swagger2openapi update

This commit is contained in:
Roman Hotsiy 2017-11-15 16:16:28 +02:00
parent 1c5730ca27
commit bc1e06fe37
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 1 additions and 18 deletions

View File

@ -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<OpenAPISpec> {
console.warn('[ReDoc Compatibility mode]: Converting OpenAPI 2.0 to OpenAPI 3.0');
return new Promise<OpenAPISpec>((resolve, reject) =>
convertObj(spec, {}, (err, res) => {
// TODO: log any warnings

View File

@ -42,7 +42,6 @@ module.exports = env => {
node: {
fs: 'empty',
crypto: 'empty',
},
externals: {