@skmtc/core 0.43.0 → 0.44.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/esm/context/ParseContext.d.ts +4 -2
- package/esm/context/ParseContext.js +23 -8
- package/esm/context/generateTypes.d.ts +3 -2
- package/esm/helpers/refFns.d.ts +8 -3
- package/esm/helpers/refFns.js +26 -9
- package/esm/oas/ref/DanglingRefError.d.ts +18 -3
- package/esm/oas/ref/DanglingRefError.js +17 -4
- package/esm/oas/ref/Ref.d.ts +23 -13
- package/esm/oas/ref/Ref.js +56 -37
- package/esm/parse/anyOfSystem.js +6 -8
- package/esm/parse/securityRequirements.d.ts +6 -0
- package/esm/parse/securityRequirements.js +10 -3
- package/esm/parse/v3-0/schema/toSchemasV3.js +3 -3
- package/esm/parse/v3-1/schema/toSchemasV3.js +3 -3
- package/esm/parse/v3-2/schema/toSchemasV3.js +3 -3
- package/package.json +1 -1
- package/script/context/ParseContext.d.ts +4 -2
- package/script/context/ParseContext.js +23 -8
- package/script/context/generateTypes.d.ts +3 -2
- package/script/helpers/refFns.d.ts +8 -3
- package/script/helpers/refFns.js +27 -10
- package/script/oas/ref/DanglingRefError.d.ts +18 -3
- package/script/oas/ref/DanglingRefError.js +17 -4
- package/script/oas/ref/Ref.d.ts +23 -13
- package/script/oas/ref/Ref.js +56 -37
- package/script/parse/anyOfSystem.js +6 -8
- package/script/parse/securityRequirements.d.ts +6 -0
- package/script/parse/securityRequirements.js +10 -3
- package/script/parse/v3-0/schema/toSchemasV3.js +3 -3
- package/script/parse/v3-1/schema/toSchemasV3.js +3 -3
- package/script/parse/v3-2/schema/toSchemasV3.js +3 -3
|
@@ -72,7 +72,8 @@ const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
|
72
72
|
*/
|
|
73
73
|
const toSecurityCheck = ({ parse, declared, parsed, stackTrail, context }) => {
|
|
74
74
|
const declaredSchemes = Object.keys(declared ?? {});
|
|
75
|
-
const
|
|
75
|
+
const unmodeledSchemes = declaredSchemes.filter(name => isUnmodeledScheme(declared?.[name]));
|
|
76
|
+
const failedSchemes = declaredSchemes.filter(name => !Object.hasOwn(parsed ?? {}, name) && !unmodeledSchemes.includes(name));
|
|
76
77
|
const logRootProblem = (problem) => context.logIssueNoKey({
|
|
77
78
|
stackTrail,
|
|
78
79
|
parent: undefined,
|
|
@@ -84,7 +85,7 @@ const toSecurityCheck = ({ parse, declared, parsed, stackTrail, context }) => {
|
|
|
84
85
|
const rootSecurity = parse();
|
|
85
86
|
const problems = toSchemeProblems(rootSecurity, { declaredSchemes, failedSchemes });
|
|
86
87
|
if (problems.length === 0) {
|
|
87
|
-
return { rootSecurity, rootProblem: undefined, declaredSchemes, failedSchemes, context };
|
|
88
|
+
return { rootSecurity, rootProblem: undefined, declaredSchemes, failedSchemes, unmodeledSchemes, context };
|
|
88
89
|
}
|
|
89
90
|
logRootProblem(`Root security ${problems.join(' and ')}`);
|
|
90
91
|
return {
|
|
@@ -92,6 +93,7 @@ const toSecurityCheck = ({ parse, declared, parsed, stackTrail, context }) => {
|
|
|
92
93
|
rootProblem: `Inherits root security, which ${problems.join(' and ')}`,
|
|
93
94
|
declaredSchemes,
|
|
94
95
|
failedSchemes,
|
|
96
|
+
unmodeledSchemes,
|
|
95
97
|
context
|
|
96
98
|
};
|
|
97
99
|
}
|
|
@@ -102,6 +104,7 @@ const toSecurityCheck = ({ parse, declared, parsed, stackTrail, context }) => {
|
|
|
102
104
|
rootProblem: 'Inherits root security, which is not a list of security requirement objects',
|
|
103
105
|
declaredSchemes,
|
|
104
106
|
failedSchemes,
|
|
107
|
+
unmodeledSchemes,
|
|
105
108
|
context
|
|
106
109
|
};
|
|
107
110
|
}
|
|
@@ -118,6 +121,10 @@ exports.toSecurityCheck = toSecurityCheck;
|
|
|
118
121
|
* of the scheme. When the parser removes the scheme later (one that is a
|
|
119
122
|
* `$ref` that names nothing), the item goes with it, and so is never kept
|
|
120
123
|
* without its auth.
|
|
124
|
+
*
|
|
125
|
+
* A scheme of a type core does not parse yet (`mutualTLS`) is not a
|
|
126
|
+
* dependency: it is never in the parsed document, and its
|
|
127
|
+
* `INVALID_SECURITY_SCHEME` error would remove every item that names it.
|
|
121
128
|
*/
|
|
122
129
|
const toOperationsWithValidSecurity = ({ items, check }) => {
|
|
123
130
|
return items.filter(item => {
|
|
@@ -126,7 +133,7 @@ const toOperationsWithValidSecurity = ({ items, check }) => {
|
|
|
126
133
|
: check.rootProblem;
|
|
127
134
|
if (message === undefined) {
|
|
128
135
|
const names = (item.security ?? check.rootSecurity ?? []).flatMap(({ requirement }) => Object.keys(requirement));
|
|
129
|
-
new Set(names).forEach(name => check.context.registerRef(item.stackTrail.clone(), `#/components/securitySchemes/${name}`));
|
|
136
|
+
new Set(names.filter(name => !check.unmodeledSchemes.includes(name))).forEach(name => check.context.registerRef(item.stackTrail.clone(), `#/components/securitySchemes/${name}`));
|
|
130
137
|
return true;
|
|
131
138
|
}
|
|
132
139
|
check.context.logIssueNoKey({
|
|
@@ -182,7 +182,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
182
182
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
183
183
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
184
184
|
schema,
|
|
185
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
185
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
186
186
|
system
|
|
187
187
|
});
|
|
188
188
|
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
@@ -198,7 +198,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
198
198
|
schema: withoutNullMembers(schema, 'oneOf'),
|
|
199
199
|
// A member's own `allOf`, or a member merged with the keywords beside
|
|
200
200
|
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
201
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
201
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
202
202
|
system,
|
|
203
203
|
groupType: 'oneOf'
|
|
204
204
|
});
|
|
@@ -267,7 +267,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
267
267
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
268
268
|
schema: withoutNullMembers(schema, 'anyOf'),
|
|
269
269
|
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
270
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
270
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
271
271
|
system,
|
|
272
272
|
groupType: 'anyOf'
|
|
273
273
|
});
|
|
@@ -234,7 +234,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
234
234
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
235
235
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
236
236
|
schema: wrapper,
|
|
237
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
237
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
238
238
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
239
239
|
system
|
|
240
240
|
});
|
|
@@ -268,7 +268,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
268
268
|
schema: withoutNull,
|
|
269
269
|
// A member's own `allOf`, or a member merged with the keywords beside
|
|
270
270
|
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
271
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
271
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
272
272
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
273
273
|
system,
|
|
274
274
|
groupType: 'oneOf'
|
|
@@ -350,7 +350,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
350
350
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
351
351
|
schema: withoutNull,
|
|
352
352
|
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
353
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
353
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
354
354
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
355
355
|
system,
|
|
356
356
|
groupType: 'anyOf'
|
|
@@ -234,7 +234,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
234
234
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
235
235
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
236
236
|
schema: wrapper,
|
|
237
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
237
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
238
238
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
239
239
|
system
|
|
240
240
|
});
|
|
@@ -268,7 +268,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
268
268
|
schema: withoutNull,
|
|
269
269
|
// A member's own `allOf`, or a member merged with the keywords beside
|
|
270
270
|
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
271
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
271
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
272
272
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
273
273
|
system,
|
|
274
274
|
groupType: 'oneOf'
|
|
@@ -350,7 +350,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
350
350
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
351
351
|
schema: withoutNull,
|
|
352
352
|
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
353
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject,
|
|
353
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, error => context.toDanglingAllOfMember({ error, stackTrail })),
|
|
354
354
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
355
355
|
system,
|
|
356
356
|
groupType: 'anyOf'
|