api 4.1.1 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api",
3
- "version": "4.1.1",
3
+ "version": "4.2.1",
4
4
  "description": "Generate an SDK from an OpenAPI definition",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -23,10 +23,10 @@
23
23
  "node": "^12 || ^14 || ^16"
24
24
  },
25
25
  "dependencies": {
26
- "@readme/oas-to-har": "^14.0.0",
27
- "@readme/openapi-parser": "^1.1.0",
26
+ "@readme/oas-to-har": "^14.0.5",
27
+ "@readme/openapi-parser": "^2.0.0",
28
28
  "datauri": "^4.1.0",
29
- "fetch-har": "^5.0.0",
29
+ "fetch-har": "^5.0.5",
30
30
  "find-cache-dir": "^3.3.1",
31
31
  "form-data": "^4.0.0",
32
32
  "get-stream": "^6.0.0",
@@ -34,11 +34,11 @@
34
34
  "make-dir": "^3.1.0",
35
35
  "mimer": "^2.0.2",
36
36
  "node-fetch": "^2.6.0",
37
- "oas": "^17.1.0"
37
+ "oas": "^17.4.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@readme/eslint-config": "^8.0.2",
41
- "@readme/oas-examples": "^4.3.2",
41
+ "@readme/oas-examples": "^4.3.3",
42
42
  "eslint": "^8.3.0",
43
43
  "jest": "^27.3.1",
44
44
  "memfs": "^3.2.4",
@@ -51,5 +51,5 @@
51
51
  "__tests__/__fixtures__/"
52
52
  ]
53
53
  },
54
- "gitHead": "07317288fb424c9bfbeb61f64a29a77a740eb8c3"
54
+ "gitHead": "0cdb386e34d37de51ce8909f5dc9c4cd338ef4de"
55
55
  }
@@ -6,18 +6,16 @@ const {
6
6
 
7
7
  module.exports = async function getResponseBody(response) {
8
8
  const contentType = response.headers.get('Content-Type');
9
- const isJson = contentType && (matchesMimeType.json(contentType) || matchesMimeType.wildcard(contentType));
9
+ const isJSON = contentType && (matchesMimeType.json(contentType) || matchesMimeType.wildcard(contentType));
10
10
 
11
- // We have to clone it before reading, just incase
12
- // we cannot parse it as JSON later, then we can
13
- // re-read again as plain text
14
- const clonedResponse = response.clone();
15
- let responseBody;
11
+ const responseBody = await response.text();
16
12
 
17
- try {
18
- responseBody = await response[isJson ? 'json' : 'text']();
19
- } catch (e) {
20
- responseBody = await clonedResponse.text();
13
+ if (isJSON) {
14
+ try {
15
+ return JSON.parse(responseBody);
16
+ } catch (e) {
17
+ // If our JSON parsing failed then we can just return plaintext instead.
18
+ }
21
19
  }
22
20
 
23
21
  return responseBody;