@redocly/openapi-core 0.0.0-snapshot.1775468574 → 0.0.0-snapshot.1775489865
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-required-schema-properties-undefined.d.ts","sourceRoot":"","sources":["../../../src/rules/common/no-required-schema-properties-undefined.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"no-required-schema-properties-undefined.d.ts","sourceRoot":"","sources":["../../../src/rules/common/no-required-schema-properties-undefined.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AASjG,eAAO,MAAM,mCAAmC,EAC5C,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,UAAU,GACV,WA+EH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isRef } from '../../ref-utils.js';
|
|
2
1
|
import { getOwn } from '../../utils/get-own.js';
|
|
2
|
+
import { isNotEmptyArray } from '../../utils/is-not-empty-array.js';
|
|
3
|
+
import { resolveSchema } from '../utils.js';
|
|
3
4
|
export const NoRequiredSchemaPropertiesUndefined = () => {
|
|
4
5
|
const parents = [];
|
|
5
6
|
return {
|
|
@@ -7,67 +8,52 @@ export const NoRequiredSchemaPropertiesUndefined = () => {
|
|
|
7
8
|
leave(_) {
|
|
8
9
|
parents.pop();
|
|
9
10
|
},
|
|
10
|
-
enter(
|
|
11
|
-
parents.push(
|
|
12
|
-
if (!
|
|
11
|
+
enter(currentSchema, ctx) {
|
|
12
|
+
parents.push(currentSchema);
|
|
13
|
+
if (!currentSchema.required)
|
|
13
14
|
return;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const hasProperty = (schemaOrRef, propertyName, visited, resolveFrom) => {
|
|
16
|
+
const { schema, location } = resolveSchema(schemaOrRef, ctx, resolveFrom);
|
|
17
|
+
if (!schema || visited.has(schema))
|
|
18
|
+
return false;
|
|
19
|
+
visited.add(schema);
|
|
20
|
+
if (schema.properties && getOwn(schema.properties, propertyName) !== undefined) {
|
|
21
|
+
return true;
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const resolved = resolve(schema, from);
|
|
23
|
-
if (!resolved.node) {
|
|
24
|
-
return {};
|
|
25
|
-
}
|
|
26
|
-
return elevateProperties(resolved.node, resolved.location?.source.absoluteRef);
|
|
23
|
+
if (schema.allOf?.some((s) => hasProperty(s, propertyName, visited, location))) {
|
|
24
|
+
return true;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
if (isNotEmptyArray(schema.anyOf) &&
|
|
27
|
+
schema.anyOf.every((s) => hasProperty(s, propertyName, new Set(visited), location))) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (isNotEmptyArray(schema.oneOf) &&
|
|
31
|
+
schema.oneOf.every((s) => hasProperty(s, propertyName, new Set(visited), location))) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
33
35
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const getParentSchema = (lookupIndex) => {
|
|
40
|
-
lookupIndex++;
|
|
41
|
-
if (!parents || parents.length < lookupIndex)
|
|
42
|
-
return undefined;
|
|
43
|
-
const parent = parents[parents.length - lookupIndex];
|
|
44
|
-
return parent;
|
|
36
|
+
const isCompositionChild = (parent, child) => {
|
|
37
|
+
const matchesChild = (s) => resolveSchema(s, ctx).schema === child;
|
|
38
|
+
return !!(parent.allOf?.some(matchesChild) ||
|
|
39
|
+
parent.anyOf?.some(matchesChild) ||
|
|
40
|
+
parent.oneOf?.some(matchesChild));
|
|
45
41
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
: undefined;
|
|
53
|
-
const grandParentProperties = splitLocation.length >= locationLookupIndex + locationLookupIndex
|
|
54
|
-
? recursivelyGetParentProperties(splitLocation.slice(0, -locationLookupIndex), parentLookupIndex)
|
|
55
|
-
: {};
|
|
56
|
-
return parentSchema
|
|
57
|
-
? {
|
|
58
|
-
...elevateProperties(parentSchema, undefined, false),
|
|
59
|
-
...grandParentProperties,
|
|
60
|
-
}
|
|
42
|
+
const findCompositionRoot = (i, child) => {
|
|
43
|
+
if (i < 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
const parent = parents[i];
|
|
46
|
+
return isCompositionChild(parent, child)
|
|
47
|
+
? (findCompositionRoot(i - 1, parent) ?? parent)
|
|
61
48
|
: undefined;
|
|
62
49
|
};
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
location: location.child(['required', i]),
|
|
50
|
+
const compositionRoot = findCompositionRoot(parents.length - 2, currentSchema);
|
|
51
|
+
for (const [i, requiredProperty] of currentSchema.required.entries()) {
|
|
52
|
+
if (!hasProperty(currentSchema, requiredProperty, new Set()) &&
|
|
53
|
+
!hasProperty(compositionRoot, requiredProperty, new Set())) {
|
|
54
|
+
ctx.report({
|
|
55
|
+
message: `Required property '${requiredProperty}' is not defined.`,
|
|
56
|
+
location: ctx.location.child(['required', i]),
|
|
71
57
|
});
|
|
72
58
|
}
|
|
73
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-required-schema-properties-undefined.js","sourceRoot":"","sources":["../../../src/rules/common/no-required-schema-properties-undefined.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-required-schema-properties-undefined.js","sourceRoot":"","sources":["../../../src/rules/common/no-required-schema-properties-undefined.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,MAAM,CAAC,MAAM,mCAAmC,GAK9B,GAAG,EAAE;IACrB,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,OAAO;QACL,MAAM,EAAE;YACN,KAAK,CAAC,CAAY;gBAChB,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC;YACD,KAAK,CAAC,aAAwB,EAAE,GAAgB;gBAC9C,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC5B,IAAI,CAAC,aAAa,CAAC,QAAQ;oBAAE,OAAO;gBAEpC,MAAM,WAAW,GAAG,CAClB,WAAkC,EAClC,YAAoB,EACpB,OAAuB,EACvB,WAAoB,EACX,EAAE;oBACX,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;oBAC1E,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;wBAAE,OAAO,KAAK,CAAC;oBACjD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBAEpB,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;wBAC/E,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;wBAC/E,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