persona-community-5/.pnpm-store/v3/files/9c/3e84f32bbac11bd2418550153293e40871a7cd05bb360fb848ebc95dcd66fce6603d9ee25d0608f029edb5952f0e75aaf813ac64724f6695291305c845a024
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

43 lines
1.7 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScalarPropertyMissingExample = void 0;
const oas_types_1 = require("../../oas-types");
const SCALAR_TYPES = ['string', 'integer', 'number', 'boolean', 'null'];
const ScalarPropertyMissingExample = () => {
return {
SchemaProperties(properties, { report, location, oasVersion, resolve }) {
for (const propName of Object.keys(properties)) {
const propSchema = resolve(properties[propName]).node;
if (!propSchema || !isScalarSchema(propSchema)) {
continue;
}
if (propSchema.example === undefined &&
propSchema.examples === undefined) {
report({
message: `Scalar property should have "example"${oasVersion === oas_types_1.SpecVersion.OAS3_1 ? ' or "examples"' : ''} defined.`,
location: location.child(propName).key(),
});
}
}
},
};
};
exports.ScalarPropertyMissingExample = ScalarPropertyMissingExample;
function isScalarSchema(schema) {
if (!schema.type) {
return false;
}
if (schema.allOf || schema.anyOf || schema.oneOf) {
// Skip allOf/oneOf/anyOf as it's complicated to validate it right now.
// We need core support for checking contrstrains through those keywords.
return false;
}
if (schema.format === 'binary') {
return false;
}
if (Array.isArray(schema.type)) {
return schema.type.every((t) => SCALAR_TYPES.includes(t));
}
return SCALAR_TYPES.includes(schema.type);
}