oas 20.8.2 → 20.8.4
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 +14 -0
- package/dist/lib/openapi-to-json-schema.js +10 -5
- package/dist/operation.js +12 -12
- package/package.json +6 -6
- package/src/lib/helpers.ts +1 -0
- package/src/lib/openapi-to-json-schema.ts +11 -5
- package/src/operation.ts +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## <small>20.8.4 (2023-05-23)</small>
|
|
2
|
+
|
|
3
|
+
* chore: minor annoying spacing fix ([20535b1](https://github.com/readmeio/oas/commit/20535b1))
|
|
4
|
+
* chore(deps-dev): bumping out of date deps ([5aa85a3](https://github.com/readmeio/oas/commit/5aa85a3))
|
|
5
|
+
* fix: ensure summaries + descriptions are strings (#764) ([2b1338e](https://github.com/readmeio/oas/commit/2b1338e)), closes [#764](https://github.com/readmeio/oas/issues/764) [/github.com/readmeio/oas/pull/764#discussion_r1203069976](https://github.com//github.com/readmeio/oas/pull/764/issues/discussion_r1203069976)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## <small>20.8.3 (2023-05-11)</small>
|
|
10
|
+
|
|
11
|
+
* feat: split mixed json schema types with booleans out into a oneOf (#763) ([0e1014a](https://github.com/readmeio/oas/commit/0e1014a)), closes [#763](https://github.com/readmeio/oas/issues/763)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
## <small>20.8.2 (2023-05-04)</small>
|
|
2
16
|
|
|
3
17
|
* feat: adding a broken skipped test, retaining soeme more jsonschema props ([94436b8](https://github.com/readmeio/oas/commit/94436b8))
|
|
@@ -411,7 +411,7 @@ function toJSONSchema(data, opts) {
|
|
|
411
411
|
if (schema.type.length === 1) {
|
|
412
412
|
schema.type = schema.type.shift();
|
|
413
413
|
}
|
|
414
|
-
else if (schema.type.includes('array') || schema.type.includes('object')) {
|
|
414
|
+
else if (schema.type.includes('array') || schema.type.includes('boolean') || schema.type.includes('object')) {
|
|
415
415
|
// If we have a `null` type but there's only two types present then we can remove `null`
|
|
416
416
|
// as an option and flag the whole schema as `nullable`.
|
|
417
417
|
var isNullable_1 = schema.type.includes('null');
|
|
@@ -422,10 +422,11 @@ function toJSONSchema(data, opts) {
|
|
|
422
422
|
// If this mixed type has non-primitives then we for convenience of our implementation
|
|
423
423
|
// we're moving them into a `oneOf`.
|
|
424
424
|
var nonPrimitives_1 = [];
|
|
425
|
-
// Because
|
|
426
|
-
//
|
|
425
|
+
// Because arrays, booleans, and objects are not compatible with any other schem type
|
|
426
|
+
// other than null we're moving them into an isolated `oneOf`, and as such want to take
|
|
427
|
+
// with it its specific properties that may be present on our current schema.
|
|
427
428
|
Object.entries({
|
|
428
|
-
// json-schema.org/understanding-json-schema/reference/array.html
|
|
429
|
+
// https://json-schema.org/understanding-json-schema/reference/array.html
|
|
429
430
|
array: [
|
|
430
431
|
'additionalItems',
|
|
431
432
|
'contains',
|
|
@@ -437,6 +438,10 @@ function toJSONSchema(data, opts) {
|
|
|
437
438
|
'prefixItems',
|
|
438
439
|
'uniqueItems',
|
|
439
440
|
],
|
|
441
|
+
// https://json-schema.org/understanding-json-schema/reference/boolean.html
|
|
442
|
+
boolean: [
|
|
443
|
+
// Booleans don't have any boolean-specific properties.
|
|
444
|
+
],
|
|
440
445
|
// https://json-schema.org/understanding-json-schema/reference/object.html
|
|
441
446
|
object: [
|
|
442
447
|
'additionalProperties',
|
|
@@ -471,7 +476,7 @@ function toJSONSchema(data, opts) {
|
|
|
471
476
|
});
|
|
472
477
|
nonPrimitives_1.push(reducedSchema);
|
|
473
478
|
});
|
|
474
|
-
schema.type = schema.type.filter(function (t) { return t !== 'array' && t !== 'object'; });
|
|
479
|
+
schema.type = schema.type.filter(function (t) { return t !== 'array' && t !== 'boolean' && t !== 'object'; });
|
|
475
480
|
if (schema.type.length === 1) {
|
|
476
481
|
schema.type = schema.type.shift();
|
|
477
482
|
}
|
package/dist/operation.js
CHANGED
|
@@ -85,20 +85,20 @@ var Operation = /** @class */ (function () {
|
|
|
85
85
|
}
|
|
86
86
|
Operation.prototype.getSummary = function () {
|
|
87
87
|
var _a;
|
|
88
|
-
if ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) {
|
|
89
|
-
return this.schema.summary
|
|
88
|
+
if (((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) && typeof this.schema.summary === 'string') {
|
|
89
|
+
return this.schema.summary;
|
|
90
90
|
}
|
|
91
|
-
else if (this.api.paths[this.path].summary) {
|
|
91
|
+
else if (this.api.paths[this.path].summary && typeof this.api.paths[this.path].summary === 'string') {
|
|
92
92
|
return this.api.paths[this.path].summary;
|
|
93
93
|
}
|
|
94
94
|
return undefined;
|
|
95
95
|
};
|
|
96
96
|
Operation.prototype.getDescription = function () {
|
|
97
97
|
var _a;
|
|
98
|
-
if ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) {
|
|
99
|
-
return this.schema.description
|
|
98
|
+
if (((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) && typeof this.schema.description === 'string') {
|
|
99
|
+
return this.schema.description;
|
|
100
100
|
}
|
|
101
|
-
else if (this.api.paths[this.path].description) {
|
|
101
|
+
else if (this.api.paths[this.path].description && typeof this.api.paths[this.path].description === 'string') {
|
|
102
102
|
return this.api.paths[this.path].description;
|
|
103
103
|
}
|
|
104
104
|
return undefined;
|
|
@@ -709,20 +709,20 @@ var Callback = /** @class */ (function (_super) {
|
|
|
709
709
|
};
|
|
710
710
|
Callback.prototype.getSummary = function () {
|
|
711
711
|
var _a;
|
|
712
|
-
if ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) {
|
|
713
|
-
return this.schema.summary
|
|
712
|
+
if (((_a = this.schema) === null || _a === void 0 ? void 0 : _a.summary) && typeof this.schema.summary === 'string') {
|
|
713
|
+
return this.schema.summary;
|
|
714
714
|
}
|
|
715
|
-
else if (this.parentSchema.summary) {
|
|
715
|
+
else if (this.parentSchema.summary && typeof this.parentSchema.summary === 'string') {
|
|
716
716
|
return this.parentSchema.summary;
|
|
717
717
|
}
|
|
718
718
|
return undefined;
|
|
719
719
|
};
|
|
720
720
|
Callback.prototype.getDescription = function () {
|
|
721
721
|
var _a;
|
|
722
|
-
if ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) {
|
|
723
|
-
return this.schema.description
|
|
722
|
+
if (((_a = this.schema) === null || _a === void 0 ? void 0 : _a.description) && typeof this.schema.description === 'string') {
|
|
723
|
+
return this.schema.description;
|
|
724
724
|
}
|
|
725
|
-
else if (this.parentSchema.description) {
|
|
725
|
+
else if (this.parentSchema.description && typeof this.parentSchema.description === 'string') {
|
|
726
726
|
return this.parentSchema.description;
|
|
727
727
|
}
|
|
728
728
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oas",
|
|
3
|
-
"version": "20.8.
|
|
3
|
+
"version": "20.8.4",
|
|
4
4
|
"description": "Comprehensive tooling for working with OpenAPI definitions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ReadMe <support@readme.io> (https://readme.com)",
|
|
@@ -53,21 +53,21 @@
|
|
|
53
53
|
"jsonpointer": "^5.0.0",
|
|
54
54
|
"memoizee": "^0.4.14",
|
|
55
55
|
"oas-normalize": "^8.4.0",
|
|
56
|
-
"openapi-types": "^12.1.
|
|
56
|
+
"openapi-types": "^12.1.1",
|
|
57
57
|
"path-to-regexp": "^6.2.0",
|
|
58
58
|
"remove-undefined-objects": "^2.0.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@commitlint/cli": "^17.6.
|
|
62
|
-
"@commitlint/config-conventional": "^17.6.
|
|
61
|
+
"@commitlint/cli": "^17.6.3",
|
|
62
|
+
"@commitlint/config-conventional": "^17.6.3",
|
|
63
63
|
"@readme/eslint-config": "^10.5.2",
|
|
64
64
|
"@readme/oas-examples": "^5.11.1",
|
|
65
65
|
"@readme/openapi-parser": "^2.5.0",
|
|
66
66
|
"@types/jest": "^29.5.1",
|
|
67
67
|
"@types/json-schema-merge-allof": "^0.6.1",
|
|
68
68
|
"@types/memoizee": "^0.4.6",
|
|
69
|
-
"@types/node": "^
|
|
70
|
-
"eslint": "^8.
|
|
69
|
+
"@types/node": "^20.2.3",
|
|
70
|
+
"eslint": "^8.41.0",
|
|
71
71
|
"husky": "^8.0.3",
|
|
72
72
|
"jest": "^29.5.0",
|
|
73
73
|
"prettier": "^2.8.8",
|
package/src/lib/helpers.ts
CHANGED
|
@@ -7,6 +7,7 @@ export function hasSchemaType(schema: SchemaObject, discriminator: 'array' | 'ob
|
|
|
7
7
|
|
|
8
8
|
return schema.type === discriminator;
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
export function isPrimitive(val: unknown): boolean {
|
|
11
12
|
return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';
|
|
12
13
|
}
|
|
@@ -456,7 +456,7 @@ export default function toJSONSchema(
|
|
|
456
456
|
// We don't need `type: [<type>]` when we can just as easily make it `type: <type>`.
|
|
457
457
|
if (schema.type.length === 1) {
|
|
458
458
|
schema.type = schema.type.shift();
|
|
459
|
-
} else if (schema.type.includes('array') || schema.type.includes('object')) {
|
|
459
|
+
} else if (schema.type.includes('array') || schema.type.includes('boolean') || schema.type.includes('object')) {
|
|
460
460
|
// If we have a `null` type but there's only two types present then we can remove `null`
|
|
461
461
|
// as an option and flag the whole schema as `nullable`.
|
|
462
462
|
const isNullable = schema.type.includes('null');
|
|
@@ -468,10 +468,11 @@ export default function toJSONSchema(
|
|
|
468
468
|
// we're moving them into a `oneOf`.
|
|
469
469
|
const nonPrimitives: any[] = [];
|
|
470
470
|
|
|
471
|
-
// Because
|
|
472
|
-
//
|
|
471
|
+
// Because arrays, booleans, and objects are not compatible with any other schem type
|
|
472
|
+
// other than null we're moving them into an isolated `oneOf`, and as such want to take
|
|
473
|
+
// with it its specific properties that may be present on our current schema.
|
|
473
474
|
Object.entries({
|
|
474
|
-
// json-schema.org/understanding-json-schema/reference/array.html
|
|
475
|
+
// https://json-schema.org/understanding-json-schema/reference/array.html
|
|
475
476
|
array: [
|
|
476
477
|
'additionalItems',
|
|
477
478
|
'contains',
|
|
@@ -484,6 +485,11 @@ export default function toJSONSchema(
|
|
|
484
485
|
'uniqueItems',
|
|
485
486
|
],
|
|
486
487
|
|
|
488
|
+
// https://json-schema.org/understanding-json-schema/reference/boolean.html
|
|
489
|
+
boolean: [
|
|
490
|
+
// Booleans don't have any boolean-specific properties.
|
|
491
|
+
],
|
|
492
|
+
|
|
487
493
|
// https://json-schema.org/understanding-json-schema/reference/object.html
|
|
488
494
|
object: [
|
|
489
495
|
'additionalProperties',
|
|
@@ -521,7 +527,7 @@ export default function toJSONSchema(
|
|
|
521
527
|
nonPrimitives.push(reducedSchema);
|
|
522
528
|
});
|
|
523
529
|
|
|
524
|
-
schema.type = schema.type.filter(t => t !== 'array' && t !== 'object');
|
|
530
|
+
schema.type = schema.type.filter(t => t !== 'array' && t !== 'boolean' && t !== 'object');
|
|
525
531
|
if (schema.type.length === 1) {
|
|
526
532
|
schema.type = schema.type.shift();
|
|
527
533
|
}
|
package/src/operation.ts
CHANGED
|
@@ -78,9 +78,9 @@ export default class Operation {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
getSummary(): string {
|
|
81
|
-
if (this.schema?.summary) {
|
|
82
|
-
return this.schema.summary
|
|
83
|
-
} else if (this.api.paths[this.path].summary) {
|
|
81
|
+
if (this.schema?.summary && typeof this.schema.summary === 'string') {
|
|
82
|
+
return this.schema.summary;
|
|
83
|
+
} else if (this.api.paths[this.path].summary && typeof this.api.paths[this.path].summary === 'string') {
|
|
84
84
|
return this.api.paths[this.path].summary;
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -88,9 +88,9 @@ export default class Operation {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
getDescription(): string {
|
|
91
|
-
if (this.schema?.description) {
|
|
92
|
-
return this.schema.description
|
|
93
|
-
} else if (this.api.paths[this.path].description) {
|
|
91
|
+
if (this.schema?.description && typeof this.schema.description === 'string') {
|
|
92
|
+
return this.schema.description;
|
|
93
|
+
} else if (this.api.paths[this.path].description && typeof this.api.paths[this.path].description === 'string') {
|
|
94
94
|
return this.api.paths[this.path].description;
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -854,9 +854,9 @@ export class Callback extends Operation {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
getSummary(): string {
|
|
857
|
-
if (this.schema?.summary) {
|
|
858
|
-
return this.schema.summary
|
|
859
|
-
} else if (this.parentSchema.summary) {
|
|
857
|
+
if (this.schema?.summary && typeof this.schema.summary === 'string') {
|
|
858
|
+
return this.schema.summary;
|
|
859
|
+
} else if (this.parentSchema.summary && typeof this.parentSchema.summary === 'string') {
|
|
860
860
|
return this.parentSchema.summary;
|
|
861
861
|
}
|
|
862
862
|
|
|
@@ -864,9 +864,9 @@ export class Callback extends Operation {
|
|
|
864
864
|
}
|
|
865
865
|
|
|
866
866
|
getDescription(): string {
|
|
867
|
-
if (this.schema?.description) {
|
|
868
|
-
return this.schema.description
|
|
869
|
-
} else if (this.parentSchema.description) {
|
|
867
|
+
if (this.schema?.description && typeof this.schema.description === 'string') {
|
|
868
|
+
return this.schema.description;
|
|
869
|
+
} else if (this.parentSchema.description && typeof this.parentSchema.description === 'string') {
|
|
870
870
|
return this.parentSchema.description;
|
|
871
871
|
}
|
|
872
872
|
|