Skip to content

Commit 86e7cc5

Browse files
authored
Merge pull request #1158 from lquixada/master
Dropped isomorphic-fetch in favor of cross-fetch (React Native compatible)
2 parents 581f181 + a9c61c0 commit 86e7cc5

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ This lib exposes these functionalities:
6464
HTTP Client
6565
-----------
6666

67-
`Swagger.http(req)` exposes a [Fetch-like interface](https://github.com/matthew-andrews/isomorphic-fetch) with a twist: allowing `url` in the request object so that it can be passed around and mutated. It extends Fetch to support request and response interceptors and performs response & header serialization. This method could be overridden to change how SwaggerJS performs HTTP requests.
67+
`Swagger.http(req)` exposes a [Fetch-like interface](https://github.com/lquixada/cross-fetch) with a twist: allowing `url` in the request object so that it can be passed around and mutated. It extends Fetch to support request and response interceptors and performs response & header serialization. This method could be overridden to change how SwaggerJS performs HTTP requests.
6868

6969
```js
7070
// Fetch-like, but support `url`, `query` and `xxxInterceptor`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
"babel-runtime": "^6.23.0",
6666
"btoa": "1.1.2",
6767
"cookie": "^0.3.1",
68+
"cross-fetch": "0.0.8",
6869
"deep-extend": "^0.4.1",
6970
"fast-json-patch": "1.1.8",
70-
"isomorphic-fetch": "2.2.1",
7171
"isomorphic-form-data": "0.0.1",
7272
"js-yaml": "^3.8.1",
7373
"lodash": "^4.16.2",

src/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'isomorphic-fetch'
1+
import 'cross-fetch/polyfill'
22
import qs from 'qs'
33
import jsYaml from 'js-yaml'
44
import isString from 'lodash/isString'

src/specmap/lib/refs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fetch from 'isomorphic-fetch'
1+
import {fetch} from 'cross-fetch'
22
import url from 'url'
33
import lib from '../lib'
44
import createError from '../lib/create-error'

test/http.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ describe('http', () => {
105105
describe('serializeHeaders', function () {
106106
it('should handle FetchAPI Headers object, which is iterable', function () {
107107
// Given
108-
// isomorphic-fetch exposes FetchAPI methods onto global
109-
require('isomorphic-fetch')
108+
// cross-fetch exposes FetchAPI methods onto global
109+
require('cross-fetch/polyfill')
110110
expect(global.Headers).toBeA(Function)
111111
const headers = new Headers() // eslint-disable-line no-undef
112112
headers.append('Authorization', 'Basic hoop-la')
@@ -124,8 +124,8 @@ describe('http', () => {
124124

125125
it('should handle two of the same headers', function () {
126126
// Given
127-
// isomorphic-fetch exposes FetchAPI methods onto global
128-
require('isomorphic-fetch')
127+
// cross-fetch exposes FetchAPI methods onto global
128+
require('cross-fetch/polyfill')
129129
expect(global.Headers).toBeA(Function)
130130
const headers = new Headers() // eslint-disable-line no-undef
131131
headers.append('Authorization', 'Basic hoop-la')
@@ -142,8 +142,8 @@ describe('http', () => {
142142

143143
it('should handle multiple headers', function () {
144144
// Given
145-
// isomorphic-fetch exposes FetchAPI methods onto global
146-
require('isomorphic-fetch')
145+
// cross-fetch exposes FetchAPI methods onto global
146+
require('cross-fetch/polyfill')
147147
expect(global.Headers).toBeA(Function)
148148
const headers = new Headers() // eslint-disable-line no-undef
149149
headers.append('Authorization', 'Basic hoop-la')

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe('constructor', () => {
180180

181181
it('should serialize the response', function () {
182182
// Given
183-
require('isomorphic-fetch') // To ensure global.Headers
183+
require('cross-fetch/polyfill') // To ensure global.Headers
184184
const xapp = xmock().get('https://swagger.io/one', function (req, res, next) {
185185
res.set('hi', 'ho')
186186
return res.send({me: true})

0 commit comments

Comments
 (0)