-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmiddleware.ts
29 lines (25 loc) · 928 Bytes
/
middleware.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {
APISchema,
FieldDataType,
RequestSchema as RequestParameter,
ResponseProperty,
ValidatorDefinition,
} from '@vulcan/core';
import { DeepPartial } from 'ts-essentials';
export interface RawRequestParameter
extends Omit<RequestParameter, 'validators'> {
validators: Array<ValidatorDefinition | string>;
}
export interface RawResponseProperty extends Omit<ResponseProperty, 'type'> {
type: string | FieldDataType | Array<RawResponseProperty>;
}
export interface RawAPISchema
extends DeepPartial<Omit<APISchema, 'request' | 'response'>> {
/** Indicate the identifier of this schema from the source, it might be uuid, file path, url ...etc, depend on the provider */
sourceName: string;
request?: DeepPartial<RawRequestParameter[]>;
response?: DeepPartial<RawResponseProperty[]>;
}
export interface SchemaParserMiddleware {
(schema: RawAPISchema, next: () => Promise<void>): Promise<void>;
}