mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
chore: add fetch only for browser
This commit is contained in:
parent
0acef35775
commit
a70f9f13dc
|
@ -1,12 +1,11 @@
|
||||||
/* tslint:disable-next-line:no-implicit-dependencies */
|
/* tslint:disable-next-line:no-implicit-dependencies */
|
||||||
import { convertObj } from 'swagger2openapi';
|
import { convertObj } from 'swagger2openapi';
|
||||||
import { OpenAPISpec } from '../types';
|
import { OpenAPISpec } from '../types';
|
||||||
import { Source, Document, bundle, Config, RawConfig } from '@redocly/openapi-core';
|
import { Source, Document, bundle, Config } from '@redocly/openapi-core';
|
||||||
import { IS_BROWSER } from './dom';
|
import { IS_BROWSER } from './dom';
|
||||||
|
|
||||||
export async function loadAndBundleSpec(specUrlOrObject: object | string): Promise<OpenAPISpec> {
|
export async function loadAndBundleSpec(specUrlOrObject: object | string): Promise<OpenAPISpec> {
|
||||||
const rawConfig: RawConfig = {};
|
const config = new Config({});
|
||||||
const config = new Config(rawConfig);
|
|
||||||
const bundleOpts = {
|
const bundleOpts = {
|
||||||
config,
|
config,
|
||||||
base: IS_BROWSER ? window.location.href : process.cwd()
|
base: IS_BROWSER ? window.location.href : process.cwd()
|
||||||
|
@ -18,7 +17,9 @@ export async function loadAndBundleSpec(specUrlOrObject: object | string): Promi
|
||||||
parsed: specUrlOrObject
|
parsed: specUrlOrObject
|
||||||
} as Document
|
} as Document
|
||||||
} else {
|
} else {
|
||||||
config.resolve.http.customFetch = fetch;
|
if (IS_BROWSER) {
|
||||||
|
config.resolve.http.customFetch = global.fetch;
|
||||||
|
}
|
||||||
bundleOpts['ref'] = specUrlOrObject;
|
bundleOpts['ref'] = specUrlOrObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user