UNPKG

@redocly/openapi-core

Version:

See https://github.com/Redocly/redocly-cli

32 lines 1.47 kB
import { isDefined } from '../../utils/is-defined.js'; import { isPlainObject } from '../../utils/is-plain-object.js'; import { validateExample } from '../utils.js'; export const NoInvalidParameterExamples = (opts) => { return { Parameter: { leave(parameter, ctx) { if (isDefined(parameter.example)) { validateExample(parameter.example, parameter.schema, { location: ctx.location.child('example'), ctx, allowAdditionalProperties: !!opts.allowAdditionalProperties, ajvContext: { apiContext: 'request' }, }); } if (isPlainObject(parameter.examples)) { for (const [key, example] of Object.entries(parameter.examples)) { if (isPlainObject(example) && 'value' in example) { validateExample(example.value, parameter.schema, { location: ctx.location.child(['examples', key]), ctx, allowAdditionalProperties: !!opts.allowAdditionalProperties, ajvContext: { apiContext: 'request' }, }); } } } }, }, }; }; //# sourceMappingURL=no-invalid-parameter-examples.js.map