-
-
Notifications
You must be signed in to change notification settings - Fork 233
/
http-and-file.ts
23 lines (19 loc) · 756 Bytes
/
http-and-file.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { createResolveHttp, resolveFile } from '@stoplight/json-ref-readers';
import { Resolver } from '@stoplight/json-ref-resolver';
import { DEFAULT_REQUEST_OPTIONS } from '../request';
import { Agent } from 'http';
export interface IHttpAndFileResolverOptions {
agent?: Agent;
}
export const httpAndFileResolver = createHttpAndFileResolver();
// resolves files, http and https $refs, and internal $refs
export function createHttpAndFileResolver(opts?: IHttpAndFileResolverOptions): Resolver {
const resolveHttp = createResolveHttp({ ...DEFAULT_REQUEST_OPTIONS, ...opts });
return new Resolver({
resolvers: {
https: { resolve: resolveHttp },
http: { resolve: resolveHttp },
file: { resolve: resolveFile },
},
});
}