Skip to content

Commit bd8984b

Browse files
committed
Merge branch 'master' of https://github.com/OpenEVSE/ESP32_WiFi_V4.x into fix#411
2 parents 548b8cf + 4a69539 commit bd8984b

25 files changed

+13429
-7552
lines changed

.spectral.json

Lines changed: 1263 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function isObject(value) {
2+
return value !== null && typeof value === 'object';
3+
}
4+
5+
export const oasDiscriminator = (schema, _opts, { path }) => {
6+
/**
7+
* This function verifies:
8+
*
9+
* 1. The discriminator property name is defined at this schema.
10+
* 2. The discriminator property is in the required property list.
11+
*/
12+
13+
if (!isObject(schema)) return;
14+
15+
if (typeof schema.discriminator !== 'string') return;
16+
17+
const discriminatorName = schema.discriminator;
18+
19+
const results = [];
20+
21+
if (!isObject(schema.properties) || !Object.keys(schema.properties).some(k => k === discriminatorName)) {
22+
results.push({
23+
message: `The discriminator property must be defined in this schema.`,
24+
path: [...path, 'properties'],
25+
});
26+
}
27+
28+
if (!Array.isArray(schema.required) || !schema.required.some(n => n === discriminatorName)) {
29+
results.push({
30+
message: `The discriminator property must be in the required property list.`,
31+
path: [...path, 'required'],
32+
});
33+
}
34+
35+
return results;
36+
};
37+
38+
export default oasDiscriminator;

0 commit comments

Comments
 (0)