oas 17.3.2 → 17.4.3
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/@types/operation.d.ts +9 -1
- package/@types/utils.d.ts +2 -0
- package/CHANGELOG.md +37 -0
- package/dist/index.js +2 -3
- package/dist/operation.js +44 -10
- package/dist/utils.js +3 -0
- package/package.json +5 -5
- package/src/index.ts +1 -2
- package/src/operation.ts +53 -9
- package/src/utils.ts +4 -0
package/@types/operation.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export default class Operation {
|
|
|
44
44
|
response: Array<string>;
|
|
45
45
|
};
|
|
46
46
|
constructor(api: RMOAS.OASDocument, path: string, method: RMOAS.HttpMethods, operation: RMOAS.OperationObject);
|
|
47
|
+
getSummary(): string;
|
|
48
|
+
getDescription(): string;
|
|
47
49
|
getContentType(): string;
|
|
48
50
|
isFormUrlEncoded(): boolean;
|
|
49
51
|
isMultipart(): boolean;
|
|
@@ -210,7 +212,11 @@ export declare class Callback extends Operation {
|
|
|
210
212
|
* The identifier that this callback is set to.
|
|
211
213
|
*/
|
|
212
214
|
identifier: string;
|
|
213
|
-
|
|
215
|
+
/**
|
|
216
|
+
* The parent path item object that this Callback exists within.
|
|
217
|
+
*/
|
|
218
|
+
parentSchema: RMOAS.PathItemObject;
|
|
219
|
+
constructor(oas: RMOAS.OASDocument, path: string, method: RMOAS.HttpMethods, operation: RMOAS.OperationObject, identifier: string, parentPathItem: RMOAS.PathItemObject);
|
|
214
220
|
/**
|
|
215
221
|
* Return the primary identifier for this callback.
|
|
216
222
|
*
|
|
@@ -219,6 +225,8 @@ export declare class Callback extends Operation {
|
|
|
219
225
|
* @returns {string}
|
|
220
226
|
*/
|
|
221
227
|
getIdentifier(): string;
|
|
228
|
+
getSummary(): string;
|
|
229
|
+
getDescription(): string;
|
|
222
230
|
}
|
|
223
231
|
export declare class Webhook extends Operation {
|
|
224
232
|
}
|
package/@types/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import findSchemaDefinition from './lib/find-schema-definition';
|
|
2
2
|
import getSchema from './lib/get-schema';
|
|
3
|
+
declare const supportedMethods: Set<string>;
|
|
3
4
|
declare const _default: {
|
|
4
5
|
findSchemaDefinition: typeof findSchemaDefinition;
|
|
5
6
|
getSchema: typeof getSchema;
|
|
@@ -16,3 +17,4 @@ declare const _default: {
|
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
export default _default;
|
|
20
|
+
export { supportedMethods };
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
## <small>17.4.3 (2022-01-05)</small>
|
|
2
|
+
|
|
3
|
+
* fix(operation): support operations without responses (#576) ([67ec319](https://github.com/readmeio/oas/commit/67ec319)), closes [#576](https://github.com/readmeio/oas/issues/576)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## <small>17.4.2 (2022-01-05)</small>
|
|
8
|
+
|
|
9
|
+
* fix: callbacks not having path-level data to retrieve common summaries (#575) ([c7d1144](https://github.com/readmeio/oas/commit/c7d1144)), closes [#575](https://github.com/readmeio/oas/issues/575)
|
|
10
|
+
* test: adding test coverage for OpenAPI 3.1 `pathItems` components ([77b596e](https://github.com/readmeio/oas/commit/77b596e))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## <small>17.4.1 (2022-01-03)</small>
|
|
15
|
+
|
|
16
|
+
* chore(deps-dev): bump @commitlint/cli from 15.0.0 to 16.0.1 (#569) ([ca515a9](https://github.com/readmeio/oas/commit/ca515a9)), closes [#569](https://github.com/readmeio/oas/issues/569)
|
|
17
|
+
* chore(deps-dev): bump @commitlint/config-conventional (#567) ([c4c6cc0](https://github.com/readmeio/oas/commit/c4c6cc0)), closes [#567](https://github.com/readmeio/oas/issues/567)
|
|
18
|
+
* chore(deps-dev): bump @types/jest from 27.0.3 to 27.4.0 (#574) ([eb21296](https://github.com/readmeio/oas/commit/eb21296)), closes [#574](https://github.com/readmeio/oas/issues/574)
|
|
19
|
+
* chore(deps-dev): bump eslint from 8.3.0 to 8.6.0 (#570) ([0dd19b1](https://github.com/readmeio/oas/commit/0dd19b1)), closes [#570](https://github.com/readmeio/oas/issues/570)
|
|
20
|
+
* chore(deps-dev): bump eslint-plugin-jsdoc from 37.1.0 to 37.5.0 (#571) ([b21ebfe](https://github.com/readmeio/oas/commit/b21ebfe)), closes [#571](https://github.com/readmeio/oas/issues/571)
|
|
21
|
+
* chore(deps-dev): bump jest from 27.4.3 to 27.4.5 (#573) ([4266065](https://github.com/readmeio/oas/commit/4266065)), closes [#573](https://github.com/readmeio/oas/issues/573)
|
|
22
|
+
* chore(deps-dev): bump prettier from 2.5.0 to 2.5.1 (#568) ([b4548c0](https://github.com/readmeio/oas/commit/b4548c0)), closes [#568](https://github.com/readmeio/oas/issues/568)
|
|
23
|
+
* chore(deps-dev): bump ts-jest from 27.0.7 to 27.1.2 (#566) ([16edcb0](https://github.com/readmeio/oas/commit/16edcb0)), closes [#566](https://github.com/readmeio/oas/issues/566)
|
|
24
|
+
* chore(deps-dev): bump typescript from 4.5.2 to 4.5.4 (#565) ([7bafc0d](https://github.com/readmeio/oas/commit/7bafc0d)), closes [#565](https://github.com/readmeio/oas/issues/565)
|
|
25
|
+
* chore(deps): bump actions/setup-node from 2.5.0 to 2.5.1 (#564) ([125afbe](https://github.com/readmeio/oas/commit/125afbe)), closes [#564](https://github.com/readmeio/oas/issues/564)
|
|
26
|
+
* chore(deps): bump openapi-types from 9.3.1 to 10.0.0 (#572) ([43e681b](https://github.com/readmeio/oas/commit/43e681b)), closes [#572](https://github.com/readmeio/oas/issues/572)
|
|
27
|
+
* chore(deps): upgrading oas-normalize ([851cf95](https://github.com/readmeio/oas/commit/851cf95))
|
|
28
|
+
* fix: improved support for common params (#563) ([ae3cb83](https://github.com/readmeio/oas/commit/ae3cb83)), closes [#563](https://github.com/readmeio/oas/issues/563)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## 17.4.0 (2021-12-17)
|
|
33
|
+
|
|
34
|
+
* feat: adding accessors for operation summary and description (#562) ([1dd6a9f](https://github.com/readmeio/oas/commit/1dd6a9f)), closes [#562](https://github.com/readmeio/oas/issues/562)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
1
38
|
## <small>17.3.2 (2021-12-14)</small>
|
|
2
39
|
|
|
3
40
|
* fix: exclude readonly params from deprecatedProps (#561) ([3342bf2](https://github.com/readmeio/oas/commit/3342bf2)), closes [#561](https://github.com/readmeio/oas/issues/561)
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ var operation_1 = __importStar(require("./operation"));
|
|
|
78
78
|
exports.Operation = operation_1["default"];
|
|
79
79
|
exports.Callback = operation_1.Callback;
|
|
80
80
|
exports.Webhook = operation_1.Webhook;
|
|
81
|
-
var utils_1 =
|
|
81
|
+
var utils_1 = __importStar(require("./utils"));
|
|
82
82
|
exports.utils = utils_1["default"];
|
|
83
83
|
/**
|
|
84
84
|
* @param url URL to ensure that it has an HTTP protocol.
|
|
@@ -611,12 +611,11 @@ var Oas = /** @class */ (function () {
|
|
|
611
611
|
// the paths object that isn't a known HTTP method.
|
|
612
612
|
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields-7
|
|
613
613
|
// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-7
|
|
614
|
-
var supportedMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
|
|
615
614
|
var paths = {};
|
|
616
615
|
Object.keys(this.api.paths ? this.api.paths : []).forEach(function (path) {
|
|
617
616
|
paths[path] = {};
|
|
618
617
|
Object.keys(_this.api.paths[path]).forEach(function (method) {
|
|
619
|
-
if (!supportedMethods.has(method))
|
|
618
|
+
if (!utils_1.supportedMethods.has(method))
|
|
620
619
|
return;
|
|
621
620
|
paths[path][method] = _this.operation(path, method);
|
|
622
621
|
});
|
package/dist/operation.js
CHANGED
|
@@ -46,6 +46,7 @@ var get_requestbody_examples_1 = __importDefault(require("./operation/get-reques
|
|
|
46
46
|
var get_callback_examples_1 = __importDefault(require("./operation/get-callback-examples"));
|
|
47
47
|
var get_response_examples_1 = __importDefault(require("./operation/get-response-examples"));
|
|
48
48
|
var matches_mimetype_1 = __importDefault(require("./lib/matches-mimetype"));
|
|
49
|
+
var utils_1 = require("./utils");
|
|
49
50
|
var Operation = /** @class */ (function () {
|
|
50
51
|
function Operation(api, path, method, operation) {
|
|
51
52
|
this.schema = operation;
|
|
@@ -57,6 +58,20 @@ var Operation = /** @class */ (function () {
|
|
|
57
58
|
this.responseExamples = undefined;
|
|
58
59
|
this.callbackExamples = undefined;
|
|
59
60
|
}
|
|
61
|
+
Operation.prototype.getSummary = function () {
|
|
62
|
+
var _a;
|
|
63
|
+
if (this.api.paths[this.path].summary) {
|
|
64
|
+
return this.api.paths[this.path].summary;
|
|
65
|
+
}
|
|
66
|
+
return ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) ? this.schema.summary.trim() : undefined;
|
|
67
|
+
};
|
|
68
|
+
Operation.prototype.getDescription = function () {
|
|
69
|
+
var _a;
|
|
70
|
+
if (this.api.paths[this.path].description) {
|
|
71
|
+
return this.api.paths[this.path].description;
|
|
72
|
+
}
|
|
73
|
+
return ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) ? this.schema.description.trim() : undefined;
|
|
74
|
+
};
|
|
60
75
|
Operation.prototype.getContentType = function () {
|
|
61
76
|
var _this = this;
|
|
62
77
|
if (this.contentType) {
|
|
@@ -225,14 +240,16 @@ var Operation = /** @class */ (function () {
|
|
|
225
240
|
})
|
|
226
241
|
.filter(function (p) { return p; }));
|
|
227
242
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
if (this.schema.responses) {
|
|
244
|
+
this.headers.response = Object.keys(this.schema.responses)
|
|
245
|
+
// Remove the reference object because we will have already dereferenced
|
|
246
|
+
.filter(function (r) { return _this.schema.responses[r].headers; })
|
|
247
|
+
.map(function (r) {
|
|
248
|
+
// Remove the reference object because we will have already dereferenced
|
|
249
|
+
return Object.keys(_this.schema.responses[r].headers);
|
|
250
|
+
})
|
|
251
|
+
.reduce(function (a, b) { return a.concat(b); }, []);
|
|
252
|
+
}
|
|
236
253
|
// If the operation doesn't already specify a 'content-type' request header,
|
|
237
254
|
// we check if the path operation request body contains content, which implies that
|
|
238
255
|
// we should also include the 'content-type' header.
|
|
@@ -434,7 +451,7 @@ var Operation = /** @class */ (function () {
|
|
|
434
451
|
: false;
|
|
435
452
|
if (!callback || !callback[method])
|
|
436
453
|
return false;
|
|
437
|
-
return new Callback(this.api, expression, method, callback[method], identifier);
|
|
454
|
+
return new Callback(this.api, expression, method, callback[method], identifier, callback);
|
|
438
455
|
};
|
|
439
456
|
/**
|
|
440
457
|
* Retrieve an array of operations created from each callback.
|
|
@@ -453,6 +470,8 @@ var Operation = /** @class */ (function () {
|
|
|
453
470
|
var exp = cb[expression];
|
|
454
471
|
if (!RMOAS.isRef(exp)) {
|
|
455
472
|
Object.keys(exp).forEach(function (method) {
|
|
473
|
+
if (!utils_1.supportedMethods.has(method))
|
|
474
|
+
return;
|
|
456
475
|
callbackOperations.push(_this.getCallback(callback, expression, method));
|
|
457
476
|
});
|
|
458
477
|
}
|
|
@@ -501,9 +520,10 @@ var Operation = /** @class */ (function () {
|
|
|
501
520
|
exports["default"] = Operation;
|
|
502
521
|
var Callback = /** @class */ (function (_super) {
|
|
503
522
|
__extends(Callback, _super);
|
|
504
|
-
function Callback(oas, path, method, operation, identifier) {
|
|
523
|
+
function Callback(oas, path, method, operation, identifier, parentPathItem) {
|
|
505
524
|
var _this = _super.call(this, oas, path, method, operation) || this;
|
|
506
525
|
_this.identifier = identifier;
|
|
526
|
+
_this.parentSchema = parentPathItem;
|
|
507
527
|
return _this;
|
|
508
528
|
}
|
|
509
529
|
/**
|
|
@@ -516,6 +536,20 @@ var Callback = /** @class */ (function (_super) {
|
|
|
516
536
|
Callback.prototype.getIdentifier = function () {
|
|
517
537
|
return this.identifier;
|
|
518
538
|
};
|
|
539
|
+
Callback.prototype.getSummary = function () {
|
|
540
|
+
var _a;
|
|
541
|
+
if (this.parentSchema.summary) {
|
|
542
|
+
return this.parentSchema.summary;
|
|
543
|
+
}
|
|
544
|
+
return ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) ? this.schema.summary.trim() : undefined;
|
|
545
|
+
};
|
|
546
|
+
Callback.prototype.getDescription = function () {
|
|
547
|
+
var _a;
|
|
548
|
+
if (this.parentSchema.description) {
|
|
549
|
+
return this.parentSchema.description;
|
|
550
|
+
}
|
|
551
|
+
return ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) ? this.schema.description.trim() : undefined;
|
|
552
|
+
};
|
|
519
553
|
return Callback;
|
|
520
554
|
}(Operation));
|
|
521
555
|
exports.Callback = Callback;
|
package/dist/utils.js
CHANGED
|
@@ -3,10 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
+
exports.supportedMethods = void 0;
|
|
6
7
|
var find_schema_definition_1 = __importDefault(require("./lib/find-schema-definition"));
|
|
7
8
|
var get_schema_1 = __importDefault(require("./lib/get-schema"));
|
|
8
9
|
var matches_mimetype_1 = __importDefault(require("./lib/matches-mimetype"));
|
|
9
10
|
var get_parameters_as_json_schema_1 = require("./operation/get-parameters-as-json-schema");
|
|
11
|
+
var supportedMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
|
|
12
|
+
exports.supportedMethods = supportedMethods;
|
|
10
13
|
exports["default"] = {
|
|
11
14
|
findSchemaDefinition: find_schema_definition_1["default"],
|
|
12
15
|
getSchema: get_schema_1["default"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oas",
|
|
3
|
-
"version": "17.3
|
|
3
|
+
"version": "17.4.3",
|
|
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)",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"jsonpointer": "^5.0.0",
|
|
60
60
|
"memoizee": "^0.4.14",
|
|
61
61
|
"minimist": "^1.2.0",
|
|
62
|
-
"oas-normalize": "^5.0
|
|
63
|
-
"openapi-types": "^
|
|
62
|
+
"oas-normalize": "^5.1.0",
|
|
63
|
+
"openapi-types": "^10.0.0",
|
|
64
64
|
"path-to-regexp": "^6.2.0",
|
|
65
65
|
"swagger-inline": "^5.0.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^
|
|
69
|
-
"@commitlint/config-conventional": "^
|
|
68
|
+
"@commitlint/cli": "^16.0.1",
|
|
69
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
70
70
|
"@readme/eslint-config": "^8.0.2",
|
|
71
71
|
"@readme/oas-examples": "^4.3.2",
|
|
72
72
|
"@types/jest": "^27.0.2",
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { pathToRegexp, match } from 'path-to-regexp';
|
|
|
7
7
|
import getAuth from './lib/get-auth';
|
|
8
8
|
import getUserVariable from './lib/get-user-variable';
|
|
9
9
|
import Operation, { Callback, Webhook } from './operation';
|
|
10
|
-
import utils from './utils';
|
|
10
|
+
import utils, { supportedMethods } from './utils';
|
|
11
11
|
|
|
12
12
|
type PathMatch = {
|
|
13
13
|
url: {
|
|
@@ -640,7 +640,6 @@ export default class Oas {
|
|
|
640
640
|
// the paths object that isn't a known HTTP method.
|
|
641
641
|
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#fixed-fields-7
|
|
642
642
|
// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-7
|
|
643
|
-
const supportedMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
|
|
644
643
|
const paths: Record<string, Record<RMOAS.HttpMethods, Operation | Webhook>> = {};
|
|
645
644
|
|
|
646
645
|
Object.keys(this.api.paths ? this.api.paths : []).forEach(path => {
|
package/src/operation.ts
CHANGED
|
@@ -11,6 +11,7 @@ import getRequestBodyExamples from './operation/get-requestbody-examples';
|
|
|
11
11
|
import getCallbackExamples from './operation/get-callback-examples';
|
|
12
12
|
import getResponseExamples from './operation/get-response-examples';
|
|
13
13
|
import matchesMimeType from './lib/matches-mimetype';
|
|
14
|
+
import { supportedMethods } from './utils';
|
|
14
15
|
|
|
15
16
|
type SecurityType = 'Basic' | 'Bearer' | 'Query' | 'Header' | 'Cookie' | 'OAuth2' | 'http' | 'apiKey';
|
|
16
17
|
|
|
@@ -75,6 +76,22 @@ export default class Operation {
|
|
|
75
76
|
this.callbackExamples = undefined;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
getSummary(): string {
|
|
80
|
+
if (this.api.paths[this.path].summary) {
|
|
81
|
+
return this.api.paths[this.path].summary;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return this.schema?.summary ? this.schema.summary.trim() : undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
getDescription(): string {
|
|
88
|
+
if (this.api.paths[this.path].description) {
|
|
89
|
+
return this.api.paths[this.path].description;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return this.schema?.description ? this.schema.description.trim() : undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
78
95
|
getContentType(): string {
|
|
79
96
|
if (this.contentType) {
|
|
80
97
|
return this.contentType;
|
|
@@ -255,14 +272,16 @@ export default class Operation {
|
|
|
255
272
|
);
|
|
256
273
|
}
|
|
257
274
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
.filter(r => (this.schema.responses[r] as RMOAS.ResponseObject).headers)
|
|
261
|
-
.map(r =>
|
|
275
|
+
if (this.schema.responses) {
|
|
276
|
+
this.headers.response = Object.keys(this.schema.responses)
|
|
262
277
|
// Remove the reference object because we will have already dereferenced
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
.filter(r => (this.schema.responses[r] as RMOAS.ResponseObject).headers)
|
|
279
|
+
.map(r =>
|
|
280
|
+
// Remove the reference object because we will have already dereferenced
|
|
281
|
+
Object.keys((this.schema.responses[r] as RMOAS.ResponseObject).headers)
|
|
282
|
+
)
|
|
283
|
+
.reduce((a, b) => a.concat(b), []);
|
|
284
|
+
}
|
|
266
285
|
|
|
267
286
|
// If the operation doesn't already specify a 'content-type' request header,
|
|
268
287
|
// we check if the path operation request body contains content, which implies that
|
|
@@ -498,7 +517,7 @@ export default class Operation {
|
|
|
498
517
|
: false;
|
|
499
518
|
|
|
500
519
|
if (!callback || !callback[method]) return false;
|
|
501
|
-
return new Callback(this.api, expression, method, callback[method], identifier);
|
|
520
|
+
return new Callback(this.api, expression, method, callback[method], identifier, callback);
|
|
502
521
|
}
|
|
503
522
|
|
|
504
523
|
/**
|
|
@@ -519,6 +538,8 @@ export default class Operation {
|
|
|
519
538
|
|
|
520
539
|
if (!RMOAS.isRef(exp)) {
|
|
521
540
|
Object.keys(exp).forEach((method: RMOAS.HttpMethods) => {
|
|
541
|
+
if (!supportedMethods.has(method)) return;
|
|
542
|
+
|
|
522
543
|
callbackOperations.push(this.getCallback(callback, expression, method));
|
|
523
544
|
});
|
|
524
545
|
}
|
|
@@ -574,16 +595,23 @@ export class Callback extends Operation {
|
|
|
574
595
|
*/
|
|
575
596
|
identifier: string;
|
|
576
597
|
|
|
598
|
+
/**
|
|
599
|
+
* The parent path item object that this Callback exists within.
|
|
600
|
+
*/
|
|
601
|
+
parentSchema: RMOAS.PathItemObject;
|
|
602
|
+
|
|
577
603
|
constructor(
|
|
578
604
|
oas: RMOAS.OASDocument,
|
|
579
605
|
path: string,
|
|
580
606
|
method: RMOAS.HttpMethods,
|
|
581
607
|
operation: RMOAS.OperationObject,
|
|
582
|
-
identifier: string
|
|
608
|
+
identifier: string,
|
|
609
|
+
parentPathItem: RMOAS.PathItemObject
|
|
583
610
|
) {
|
|
584
611
|
super(oas, path, method, operation);
|
|
585
612
|
|
|
586
613
|
this.identifier = identifier;
|
|
614
|
+
this.parentSchema = parentPathItem;
|
|
587
615
|
}
|
|
588
616
|
|
|
589
617
|
/**
|
|
@@ -596,6 +624,22 @@ export class Callback extends Operation {
|
|
|
596
624
|
getIdentifier(): string {
|
|
597
625
|
return this.identifier;
|
|
598
626
|
}
|
|
627
|
+
|
|
628
|
+
getSummary(): string {
|
|
629
|
+
if (this.parentSchema.summary) {
|
|
630
|
+
return this.parentSchema.summary;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return this.schema?.summary ? this.schema.summary.trim() : undefined;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
getDescription(): string {
|
|
637
|
+
if (this.parentSchema.description) {
|
|
638
|
+
return this.parentSchema.description;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
return this.schema?.description ? this.schema.description.trim() : undefined;
|
|
642
|
+
}
|
|
599
643
|
}
|
|
600
644
|
|
|
601
645
|
export class Webhook extends Operation {}
|
package/src/utils.ts
CHANGED
|
@@ -3,9 +3,13 @@ import getSchema from './lib/get-schema';
|
|
|
3
3
|
import matchesMimeType from './lib/matches-mimetype';
|
|
4
4
|
import { types as jsonSchemaTypes } from './operation/get-parameters-as-json-schema';
|
|
5
5
|
|
|
6
|
+
const supportedMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
|
|
7
|
+
|
|
6
8
|
export default {
|
|
7
9
|
findSchemaDefinition,
|
|
8
10
|
getSchema,
|
|
9
11
|
jsonSchemaTypes,
|
|
10
12
|
matchesMimeType,
|
|
11
13
|
};
|
|
14
|
+
|
|
15
|
+
export { supportedMethods };
|