api 4.0.0 → 4.1.0
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 +4 -4
- package/src/index.js +4 -4
- package/src/lib/prepareParams.js +1 -1
- package/src/lib/prepareServer.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Generate an SDK from an OpenAPI definition",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": "^12 || ^14 || ^16"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@readme/oas-to-har": "^
|
|
26
|
+
"@readme/oas-to-har": "^14.0.0",
|
|
27
27
|
"@readme/openapi-parser": "^1.1.0",
|
|
28
28
|
"datauri": "^4.1.0",
|
|
29
29
|
"fetch-har": "^5.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"make-dir": "^3.1.0",
|
|
35
35
|
"mimer": "^2.0.2",
|
|
36
36
|
"node-fetch": "^2.6.0",
|
|
37
|
-
"oas": "^
|
|
37
|
+
"oas": "^17.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@readme/eslint-config": "^7.2.2",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"__tests__/__fixtures__/"
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "057c930ba9ca953bda5413baae6efec062563807"
|
|
55
55
|
}
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const fetch = require('node-fetch');
|
|
2
2
|
const fetchHar = require('fetch-har');
|
|
3
|
-
const Oas = require('oas');
|
|
3
|
+
const Oas = require('oas').default;
|
|
4
4
|
const oasToHar = require('@readme/oas-to-har');
|
|
5
5
|
const pkg = require('../package.json');
|
|
6
6
|
|
|
7
7
|
const Cache = require('./cache');
|
|
8
|
-
const { parseResponse, prepareAuth, prepareParams, prepareServer } = require('./lib
|
|
8
|
+
const { parseResponse, prepareAuth, prepareParams, prepareServer } = require('./lib');
|
|
9
9
|
|
|
10
10
|
global.fetch = fetch;
|
|
11
11
|
global.Request = fetch.Request;
|
|
@@ -19,9 +19,9 @@ class Sdk {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
static getOperations(spec) {
|
|
22
|
-
return Object.keys(spec.paths)
|
|
22
|
+
return Object.keys(spec.api.paths)
|
|
23
23
|
.map(path => {
|
|
24
|
-
return Object.keys(spec.paths[path]).map(method => {
|
|
24
|
+
return Object.keys(spec.api.paths[path]).map(method => {
|
|
25
25
|
return spec.operation(path, method);
|
|
26
26
|
});
|
|
27
27
|
})
|
package/src/lib/prepareParams.js
CHANGED
|
@@ -89,7 +89,7 @@ module.exports = async (operation, body, metadata) => {
|
|
|
89
89
|
// body payload to see if anything in there is either a file path or a file stream so we can translate those into a
|
|
90
90
|
// data URL for `@readme/oas-to-har` to make a request.
|
|
91
91
|
if ('body' in params && operation.isMultipart()) {
|
|
92
|
-
let requestBody = getSchema(operation.schema, operation.
|
|
92
|
+
let requestBody = getSchema(operation.schema, operation.api);
|
|
93
93
|
if (requestBody) {
|
|
94
94
|
requestBody = requestBody.schema;
|
|
95
95
|
} else {
|
package/src/lib/prepareServer.js
CHANGED
|
@@ -18,7 +18,7 @@ function stripTrailingSlash(url) {
|
|
|
18
18
|
module.exports = (spec, url, variables = {}) => {
|
|
19
19
|
let serverIdx;
|
|
20
20
|
const sanitizedUrl = stripTrailingSlash(url);
|
|
21
|
-
(spec.servers || []).forEach((server, i) => {
|
|
21
|
+
(spec.api.servers || []).forEach((server, i) => {
|
|
22
22
|
if (server.url === sanitizedUrl) {
|
|
23
23
|
serverIdx = i;
|
|
24
24
|
}
|