mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
Refactor: use the ajv options object instead of add* methods
This commit is contained in:
parent
d29400d59a
commit
40b7d2c6e4
@ -1,5 +1,4 @@
|
|||||||
import Ajv, { ErrorObject } from 'ajv';
|
import Ajv, { ErrorObject } from 'ajv';
|
||||||
import addFormats from 'ajv-formats';
|
|
||||||
import { SchemaId, schemas } from './index';
|
import { SchemaId, schemas } from './index';
|
||||||
import { omitKeys } from '../util/omit-keys';
|
import { omitKeys } from '../util/omit-keys';
|
||||||
|
|
||||||
@ -12,14 +11,16 @@ const ajv = new Ajv({
|
|||||||
schemas: Object.values(schemas).map((schema) =>
|
schemas: Object.values(schemas).map((schema) =>
|
||||||
omitKeys(schema, 'components'),
|
omitKeys(schema, 'components'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// example was superseded by examples in openapi 3.1, but we're still on 3.0, so
|
||||||
|
// let's add it back in!
|
||||||
|
keywords: ['example'],
|
||||||
|
formats: {
|
||||||
|
'date-time': true,
|
||||||
|
uri: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFormats(ajv, ['date-time', 'uri', 'uri-reference']);
|
|
||||||
|
|
||||||
// example was superseded by examples in openapi 3.1, but we're still on 3.0, so
|
|
||||||
// let's add it back in!
|
|
||||||
ajv.addKeyword('example');
|
|
||||||
|
|
||||||
export const validateSchema = (
|
export const validateSchema = (
|
||||||
schema: SchemaId,
|
schema: SchemaId,
|
||||||
data: unknown,
|
data: unknown,
|
||||||
|
Loading…
Reference in New Issue
Block a user