httpsnippet-client-api 3.4.1 → 4.1.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 +8 -8
- package/src/index.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "httpsnippet-client-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "An HTTP Snippet client for generating snippets for the api module.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@readme/httpsnippet": "^3.0.0",
|
|
32
|
-
"oas": "^
|
|
32
|
+
"oas": "^17.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@readme/eslint-config": "^
|
|
36
|
-
"@readme/oas-examples": "^4.2
|
|
37
|
-
"eslint": "^
|
|
38
|
-
"jest": "^27.
|
|
39
|
-
"prettier": "^2.4.
|
|
35
|
+
"@readme/eslint-config": "^8.0.2",
|
|
36
|
+
"@readme/oas-examples": "^4.3.2",
|
|
37
|
+
"eslint": "^8.3.0",
|
|
38
|
+
"jest": "^27.3.1",
|
|
39
|
+
"prettier": "^2.4.1"
|
|
40
40
|
},
|
|
41
41
|
"prettier": "@readme/eslint-config/prettier",
|
|
42
42
|
"jest": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"__tests__/__fixtures__/"
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "07317288fb424c9bfbeb61f64a29a77a740eb8c3"
|
|
48
48
|
}
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const { match } = require('path-to-regexp');
|
|
|
2
2
|
const stringifyObject = require('stringify-object');
|
|
3
3
|
const CodeBuilder = require('@readme/httpsnippet/src/helpers/code-builder');
|
|
4
4
|
const contentType = require('content-type');
|
|
5
|
-
const Oas = require('oas');
|
|
5
|
+
const Oas = require('oas').default;
|
|
6
6
|
|
|
7
7
|
function stringify(obj, opts = {}) {
|
|
8
8
|
return stringifyObject(obj, { indent: ' ', ...opts });
|
|
@@ -90,6 +90,7 @@ module.exports = function (source, options) {
|
|
|
90
90
|
|
|
91
91
|
const method = source.method.toLowerCase();
|
|
92
92
|
const oas = new Oas(opts.apiDefinition);
|
|
93
|
+
const apiDefinition = oas.getDefinition();
|
|
93
94
|
const foundOperation = oas.findOperation(source.url, method);
|
|
94
95
|
if (!foundOperation) {
|
|
95
96
|
throw new Error(
|
|
@@ -112,7 +113,7 @@ module.exports = function (source, options) {
|
|
|
112
113
|
// `oas` library then the URL either has server variables contained in it (that don't match the defaults), or the
|
|
113
114
|
// OAS offers alternate server URLs and we should expose that in the generated snippet.
|
|
114
115
|
const configData = [];
|
|
115
|
-
if ((
|
|
116
|
+
if ((apiDefinition.servers || []).length > 1) {
|
|
116
117
|
const stockUrl = oas.url();
|
|
117
118
|
const baseUrl = source.url.replace(path, '');
|
|
118
119
|
if (baseUrl !== stockUrl) {
|