mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 13:30:33 +03:00
Remove crypto hack after swagger2openapi update
This commit is contained in:
parent
1c5730ca27
commit
bc1e06fe37
|
@ -1,24 +1,8 @@
|
||||||
import { convertObj } from 'swagger2openapi';
|
import { convertObj } from 'swagger2openapi';
|
||||||
|
|
||||||
const swagger2OpenAPICommon = require('swagger2openapi/common');
|
|
||||||
import { OpenAPISpec } from '../types';
|
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> {
|
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) =>
|
return new Promise<OpenAPISpec>((resolve, reject) =>
|
||||||
convertObj(spec, {}, (err, res) => {
|
convertObj(spec, {}, (err, res) => {
|
||||||
// TODO: log any warnings
|
// TODO: log any warnings
|
||||||
|
|
|
@ -42,7 +42,6 @@ module.exports = env => {
|
||||||
|
|
||||||
node: {
|
node: {
|
||||||
fs: 'empty',
|
fs: 'empty',
|
||||||
crypto: 'empty',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
externals: {
|
externals: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user