oas 18.0.4 → 18.0.5
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 +2 -1
- package/CHANGELOG.md +6 -0
- package/dist/operation.js +5 -4
- package/package.json +1 -1
- package/src/operation.ts +5 -4
package/@types/operation.d.ts
CHANGED
|
@@ -79,7 +79,8 @@ export default class Operation {
|
|
|
79
79
|
prepareSecurity(): Record<SecurityType, RMOAS.KeyedSecuritySchemeObject[]>;
|
|
80
80
|
getHeaders(): Operation['headers'];
|
|
81
81
|
/**
|
|
82
|
-
* Determine if the operation has an operation present in its schema.
|
|
82
|
+
* Determine if the operation has an operation present in its schema. Note that if one is present
|
|
83
|
+
* in the schema but is an empty string then this will return false.
|
|
83
84
|
*
|
|
84
85
|
*/
|
|
85
86
|
hasOperationId(): boolean;
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## <small>18.0.5 (2022-03-21)</small>
|
|
2
|
+
|
|
3
|
+
* fix: `operation.hasOperationId` should return false for an empty string (#624) ([bc23a43](https://github.com/readmeio/oas/commit/bc23a43)), closes [#624](https://github.com/readmeio/oas/issues/624)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
1
7
|
## <small>18.0.4 (2022-03-21)</small>
|
|
2
8
|
|
|
3
9
|
* docs: updating the changelog for 17.8.2 ([18c853c](https://github.com/readmeio/oas/commit/18c853c))
|
package/dist/operation.js
CHANGED
|
@@ -279,11 +279,12 @@ var Operation = /** @class */ (function () {
|
|
|
279
279
|
return this.headers;
|
|
280
280
|
};
|
|
281
281
|
/**
|
|
282
|
-
* Determine if the operation has an operation present in its schema.
|
|
282
|
+
* Determine if the operation has an operation present in its schema. Note that if one is present
|
|
283
|
+
* in the schema but is an empty string then this will return false.
|
|
283
284
|
*
|
|
284
285
|
*/
|
|
285
286
|
Operation.prototype.hasOperationId = function () {
|
|
286
|
-
return 'operationId' in this.schema;
|
|
287
|
+
return Boolean('operationId' in this.schema && this.schema.operationId.length);
|
|
287
288
|
};
|
|
288
289
|
/**
|
|
289
290
|
* Get an `operationId` for this operation. If one is not present (it's not required by the spec!)
|
|
@@ -293,7 +294,7 @@ var Operation = /** @class */ (function () {
|
|
|
293
294
|
* @param opts.camelCase Generate a JS method-friendly operation ID when one isn't present.
|
|
294
295
|
*/
|
|
295
296
|
Operation.prototype.getOperationId = function (opts) {
|
|
296
|
-
if (
|
|
297
|
+
if (this.hasOperationId()) {
|
|
297
298
|
return this.schema.operationId;
|
|
298
299
|
}
|
|
299
300
|
var method = this.method.toLowerCase();
|
|
@@ -304,7 +305,7 @@ var Operation = /** @class */ (function () {
|
|
|
304
305
|
.toLowerCase();
|
|
305
306
|
if (opts === null || opts === void 0 ? void 0 : opts.camelCase) {
|
|
306
307
|
operationId = operationId.replace(/[^a-zA-Z0-9]+(.)/g, function (_, chr) { return chr.toUpperCase(); });
|
|
307
|
-
// If the generated operationId already starts with the method (eg. `getPets`) we don't want
|
|
308
|
+
// If the generated `operationId` already starts with the method (eg. `getPets`) we don't want
|
|
308
309
|
// to double it up into `getGetPets`.
|
|
309
310
|
if (operationId.startsWith(method)) {
|
|
310
311
|
return operationId;
|
package/package.json
CHANGED
package/src/operation.ts
CHANGED
|
@@ -315,11 +315,12 @@ export default class Operation {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
/**
|
|
318
|
-
* Determine if the operation has an operation present in its schema.
|
|
318
|
+
* Determine if the operation has an operation present in its schema. Note that if one is present
|
|
319
|
+
* in the schema but is an empty string then this will return false.
|
|
319
320
|
*
|
|
320
321
|
*/
|
|
321
322
|
hasOperationId(): boolean {
|
|
322
|
-
return 'operationId' in this.schema;
|
|
323
|
+
return Boolean('operationId' in this.schema && this.schema.operationId.length);
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
/**
|
|
@@ -330,7 +331,7 @@ export default class Operation {
|
|
|
330
331
|
* @param opts.camelCase Generate a JS method-friendly operation ID when one isn't present.
|
|
331
332
|
*/
|
|
332
333
|
getOperationId(opts?: { camelCase: boolean }): string {
|
|
333
|
-
if (
|
|
334
|
+
if (this.hasOperationId()) {
|
|
334
335
|
return this.schema.operationId;
|
|
335
336
|
}
|
|
336
337
|
|
|
@@ -344,7 +345,7 @@ export default class Operation {
|
|
|
344
345
|
if (opts?.camelCase) {
|
|
345
346
|
operationId = operationId.replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
|
|
346
347
|
|
|
347
|
-
// If the generated operationId already starts with the method (eg. `getPets`) we don't want
|
|
348
|
+
// If the generated `operationId` already starts with the method (eg. `getPets`) we don't want
|
|
348
349
|
// to double it up into `getGetPets`.
|
|
349
350
|
if (operationId.startsWith(method)) {
|
|
350
351
|
return operationId;
|