oas 18.0.6 → 18.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/CHANGELOG.md +19 -0
- package/dist/index.js +13 -3
- package/dist/operation.js +16 -3
- package/package.json +13 -13
- package/src/index.ts +14 -3
- package/src/operation.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 18.1.0 (2022-03-31)
|
|
2
|
+
|
|
3
|
+
* feat: moving us over to our json-schema-ref-parser fork (#629) ([b986f35](https://github.com/readmeio/oas/commit/b986f35)), closes [#629](https://github.com/readmeio/oas/issues/629)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## <small>18.0.8 (2022-03-29)</small>
|
|
8
|
+
|
|
9
|
+
* fix: improved error handling on `Oas.findOperation()` calls (#628) ([22198dd](https://github.com/readmeio/oas/commit/22198dd)), closes [#628](https://github.com/readmeio/oas/issues/628)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## <small>18.0.7 (2022-03-24)</small>
|
|
14
|
+
|
|
15
|
+
* fix: getSecurity() should return an empty array for an empty securitySchemes object (#626) ([f96bee1](https://github.com/readmeio/oas/commit/f96bee1)), closes [#626](https://github.com/readmeio/oas/issues/626)
|
|
16
|
+
* fix: issue where a securityScheme may be corrupted with internal library data (#627) ([666ba9f](https://github.com/readmeio/oas/commit/666ba9f)), closes [#627](https://github.com/readmeio/oas/issues/627)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
1
20
|
## <small>18.0.6 (2022-03-21)</small>
|
|
2
21
|
|
|
3
22
|
* feat: `camelCase` opt on `getOperationId()` should clean IDs if present (#625) ([6ab85df](https://github.com/readmeio/oas/commit/6ab85df)), closes [#625](https://github.com/readmeio/oas/issues/625)
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
74
74
|
};
|
|
75
75
|
exports.__esModule = true;
|
|
76
76
|
exports.utils = exports.Webhook = exports.Callback = exports.Operation = void 0;
|
|
77
|
-
var json_schema_ref_parser_1 = __importDefault(require("@
|
|
77
|
+
var json_schema_ref_parser_1 = __importDefault(require("@readme/json-schema-ref-parser"));
|
|
78
78
|
var path_to_regexp_1 = require("path-to-regexp");
|
|
79
79
|
var get_auth_1 = __importDefault(require("./lib/get-auth"));
|
|
80
80
|
var get_user_variable_1 = __importDefault(require("./lib/get-user-variable"));
|
|
@@ -197,14 +197,23 @@ function generatePathMatches(paths, pathName, origin) {
|
|
|
197
197
|
return Object.keys(paths)
|
|
198
198
|
.map(function (path) {
|
|
199
199
|
var cleanedPath = normalizePath(path);
|
|
200
|
-
var
|
|
201
|
-
|
|
200
|
+
var matchResult;
|
|
201
|
+
try {
|
|
202
|
+
var matchStatement = (0, path_to_regexp_1.match)(cleanedPath, { decode: decodeURIComponent });
|
|
203
|
+
matchResult = matchStatement(prunedPathName);
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
// If path matching fails for whatever reason (maybe they have a malformed path parameter)
|
|
207
|
+
// then we shouldn't also fail.
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
202
210
|
var slugs = {};
|
|
203
211
|
if (matchResult && Object.keys(matchResult.params).length) {
|
|
204
212
|
Object.keys(matchResult.params).forEach(function (param) {
|
|
205
213
|
slugs[":".concat(param)] = matchResult.params[param];
|
|
206
214
|
});
|
|
207
215
|
}
|
|
216
|
+
// eslint-disable-next-line consistent-return
|
|
208
217
|
return {
|
|
209
218
|
url: {
|
|
210
219
|
origin: origin,
|
|
@@ -216,6 +225,7 @@ function generatePathMatches(paths, pathName, origin) {
|
|
|
216
225
|
match: matchResult
|
|
217
226
|
};
|
|
218
227
|
})
|
|
228
|
+
.filter(Boolean)
|
|
219
229
|
.filter(function (p) { return p.match; });
|
|
220
230
|
}
|
|
221
231
|
/**
|
package/dist/operation.js
CHANGED
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
29
|
if (k2 === undefined) k2 = k;
|
|
19
30
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -122,7 +133,7 @@ var Operation = /** @class */ (function () {
|
|
|
122
133
|
*/
|
|
123
134
|
Operation.prototype.getSecurity = function () {
|
|
124
135
|
var _a, _b;
|
|
125
|
-
if (!((_b = (_a = this.api) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.securitySchemes)) {
|
|
136
|
+
if (!((_b = (_a = this.api) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.securitySchemes) || !Object.keys(this.api.components.securitySchemes).length) {
|
|
126
137
|
return [];
|
|
127
138
|
}
|
|
128
139
|
return this.schema.security || this.api.security || [];
|
|
@@ -185,8 +196,10 @@ var Operation = /** @class */ (function () {
|
|
|
185
196
|
else {
|
|
186
197
|
return false;
|
|
187
198
|
}
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
return {
|
|
200
|
+
type: type,
|
|
201
|
+
security: __assign(__assign({}, security), { _key: key })
|
|
202
|
+
};
|
|
190
203
|
});
|
|
191
204
|
if (filterInvalid)
|
|
192
205
|
return keysWithTypes.filter(function (key) { return key !== false; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oas",
|
|
3
|
-
"version": "18.0
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"description": "Working with OpenAPI definitions is hard. This makes it easier.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ReadMe <support@readme.io> (https://readme.com)",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"watch": "tsc --watch"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@types/json-schema": "^7.0.
|
|
52
|
+
"@readme/json-schema-ref-parser": "^1.1.0",
|
|
53
|
+
"@types/json-schema": "^7.0.11",
|
|
54
54
|
"cardinal": "^2.1.1",
|
|
55
55
|
"chalk": "^4.1.2",
|
|
56
56
|
"glob": "^7.1.2",
|
|
@@ -60,27 +60,27 @@
|
|
|
60
60
|
"jsonpointer": "^5.0.0",
|
|
61
61
|
"memoizee": "^0.4.14",
|
|
62
62
|
"minimist": "^1.2.0",
|
|
63
|
-
"oas-normalize": "^5.
|
|
63
|
+
"oas-normalize": "^5.2.0",
|
|
64
64
|
"openapi-types": "^10.0.0",
|
|
65
65
|
"path-to-regexp": "^6.2.0",
|
|
66
|
-
"swagger-inline": "^5.
|
|
66
|
+
"swagger-inline": "^5.2.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@commitlint/cli": "^16.
|
|
69
|
+
"@commitlint/cli": "^16.2.3",
|
|
70
70
|
"@commitlint/config-conventional": "^16.0.0",
|
|
71
|
-
"@readme/eslint-config": "^8.5.
|
|
72
|
-
"@readme/oas-examples": "^
|
|
71
|
+
"@readme/eslint-config": "^8.5.1",
|
|
72
|
+
"@readme/oas-examples": "^5.0.0",
|
|
73
|
+
"@readme/openapi-parser": "^2.0.4",
|
|
73
74
|
"@types/jest": "^27.0.2",
|
|
74
75
|
"@types/json-schema-merge-allof": "^0.6.1",
|
|
75
76
|
"@types/memoizee": "^0.4.6",
|
|
76
77
|
"alex": "^10.0.0",
|
|
77
|
-
"eslint": "^8.
|
|
78
|
-
"eslint-plugin-jsdoc": "^37.0.3",
|
|
78
|
+
"eslint": "^8.12.0",
|
|
79
79
|
"husky": "^7.0.2",
|
|
80
80
|
"jest": "^27.0.3",
|
|
81
|
-
"prettier": "^2.
|
|
82
|
-
"ts-jest": "^27.
|
|
83
|
-
"typescript": "^4.
|
|
81
|
+
"prettier": "^2.6.1",
|
|
82
|
+
"ts-jest": "^27.1.4",
|
|
83
|
+
"typescript": "^4.6.3"
|
|
84
84
|
},
|
|
85
85
|
"prettier": "@readme/eslint-config/prettier",
|
|
86
86
|
"commitlint": {
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as RMOAS from './rmoas.types';
|
|
|
2
2
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
3
3
|
import type { MatchResult } from 'path-to-regexp';
|
|
4
4
|
|
|
5
|
-
import $RefParser from '@
|
|
5
|
+
import $RefParser from '@readme/json-schema-ref-parser';
|
|
6
6
|
import { pathToRegexp, match } from 'path-to-regexp';
|
|
7
7
|
import getAuth from './lib/get-auth';
|
|
8
8
|
import getUserVariable from './lib/get-user-variable';
|
|
@@ -147,8 +147,17 @@ function generatePathMatches(paths: RMOAS.PathsObject, pathName: string, origin:
|
|
|
147
147
|
return Object.keys(paths)
|
|
148
148
|
.map(path => {
|
|
149
149
|
const cleanedPath = normalizePath(path);
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
|
|
151
|
+
let matchResult: MatchResult;
|
|
152
|
+
try {
|
|
153
|
+
const matchStatement = match(cleanedPath, { decode: decodeURIComponent });
|
|
154
|
+
matchResult = matchStatement(prunedPathName) as MatchResult;
|
|
155
|
+
} catch (err) {
|
|
156
|
+
// If path matching fails for whatever reason (maybe they have a malformed path parameter)
|
|
157
|
+
// then we shouldn't also fail.
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
152
161
|
const slugs: Record<string, string> = {};
|
|
153
162
|
|
|
154
163
|
if (matchResult && Object.keys(matchResult.params).length) {
|
|
@@ -157,6 +166,7 @@ function generatePathMatches(paths: RMOAS.PathsObject, pathName: string, origin:
|
|
|
157
166
|
});
|
|
158
167
|
}
|
|
159
168
|
|
|
169
|
+
// eslint-disable-next-line consistent-return
|
|
160
170
|
return {
|
|
161
171
|
url: {
|
|
162
172
|
origin,
|
|
@@ -168,6 +178,7 @@ function generatePathMatches(paths: RMOAS.PathsObject, pathName: string, origin:
|
|
|
168
178
|
match: matchResult,
|
|
169
179
|
};
|
|
170
180
|
})
|
|
181
|
+
.filter(Boolean)
|
|
171
182
|
.filter(p => p.match) as PathMatches;
|
|
172
183
|
}
|
|
173
184
|
|
package/src/operation.ts
CHANGED
|
@@ -146,7 +146,7 @@ export default class Operation {
|
|
|
146
146
|
*
|
|
147
147
|
*/
|
|
148
148
|
getSecurity(): RMOAS.SecurityRequirementObject[] {
|
|
149
|
-
if (!this.api?.components?.securitySchemes) {
|
|
149
|
+
if (!this.api?.components?.securitySchemes || !Object.keys(this.api.components.securitySchemes).length) {
|
|
150
150
|
return [];
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -204,9 +204,13 @@ export default class Operation {
|
|
|
204
204
|
return false;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
return {
|
|
208
|
+
type,
|
|
209
|
+
security: {
|
|
210
|
+
...security,
|
|
211
|
+
_key: key,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
210
214
|
});
|
|
211
215
|
|
|
212
216
|
if (filterInvalid) return keysWithTypes.filter(key => key !== false);
|