@@ -2,11 +2,14 @@ import Http from './http'
22import mapSpec , { plugins } from './specmap'
33import { normalizeSwagger } from './helpers'
44
5- export function makeFetchJSON ( http ) {
5+ export function makeFetchJSON ( http , opts = { } ) {
6+ const { requestInterceptor, responseInterceptor} = opts
67 return ( docPath ) => {
78 return http ( {
89 url : docPath ,
910 loadSpec : true ,
11+ requestInterceptor,
12+ responseInterceptor,
1013 headers : {
1114 Accept : 'application/json'
1215 } ,
@@ -23,10 +26,17 @@ export function clearCache() {
2326 plugins . refs . clearCache ( )
2427}
2528
26- export default function resolve ( {
27- http, fetch, spec, url, baseDoc, mode, allowMetaPatches = true ,
28- modelPropertyMacro, parameterMacro
29- } ) {
29+ export default function resolve ( obj ) {
30+ const {
31+ fetch, spec, url, mode, allowMetaPatches = true ,
32+ modelPropertyMacro, parameterMacro, requestInterceptor,
33+ responseInterceptor
34+ } = obj
35+
36+ let { http, baseDoc} = obj
37+
38+ // console.log(obj)
39+
3040 // @TODO Swagger-UI uses baseDoc instead of url, this is to allow both
3141 // need to fix and pick one.
3242 baseDoc = baseDoc || url
@@ -36,7 +46,7 @@ export default function resolve({
3646 http = fetch || http || Http
3747
3848 if ( ! spec ) {
39- return makeFetchJSON ( http ) ( baseDoc ) . then ( doResolve )
49+ return makeFetchJSON ( http , { requestInterceptor , responseInterceptor } ) ( baseDoc ) . then ( doResolve )
4050 }
4151
4252 return doResolve ( spec )
@@ -47,7 +57,7 @@ export default function resolve({
4757 }
4858
4959 // Build a json-fetcher ( ie: give it a URL and get json out )
50- plugins . refs . fetchJSON = makeFetchJSON ( http )
60+ plugins . refs . fetchJSON = makeFetchJSON ( http , { requestInterceptor , responseInterceptor } )
5161
5262 const plugs = [ plugins . refs ]
5363
0 commit comments