-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathinternal.ts
64 lines (57 loc) · 2.11 KB
/
internal.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as http from 'http';
import {
BodyParser,
ParametersByLocation,
ParametersMap,
IValidationError,
ValidatorFunction,
Controller,
ExegesisContext,
AuthenticationSuccess,
ControllerModule,
ExegesisResponse,
ResponseValidationResult,
ParameterLocations
} from '.';
export type ParsedParameterValidator =
(parameterValues: ParametersByLocation<ParametersMap<any>>) => IValidationError[] | null;
export interface ResolvedOperation {
parseParameters: (() => ParametersByLocation<ParametersMap<any>>);
validateParameters: ParsedParameterValidator;
parameterLocations: ParameterLocations;
bodyParser: BodyParser | undefined;
validateBody: ValidatorFunction | undefined;
exegesisControllerName: string | undefined;
operationId: string | undefined;
controllerModule: ControllerModule | undefined;
controller: Controller | undefined;
validateResponse(
response: ExegesisResponse,
validateDefaultResponses: boolean
) : ResponseValidationResult;
// Returns the authentication data, or undefined if user could not be authenticated.
authenticate(context: ExegesisContext) : Promise<{[scheme: string]: AuthenticationSuccess} | undefined>;
}
export interface ResolvedPath<T> {
operation: ResolvedOperation | undefined;
api: T;
}
// ApiInterface provides an interface into the `oas3` subdirectory. The idea here is,
// when `oas4` comes along we can support it by writing a new `oas4` subdirectory
// that implements this same interface, and then we'll be able to support oas4
// wihtout changing anything. (We'll see if this actually works. :P)
export interface ApiInterface<T> {
/**
* Resolve an incoming request.
*
* @param method - The HTTP method used (e.g. 'GET').
* @param url - The URL used to retrieve this request.
* @param headers - Any headers sent along with the request.
* @throws {ValidationError} if some parameters cannot be parsed.
*/
resolve(
method: string,
url: string,
headers: http.IncomingHttpHeaders
) : ResolvedPath<T> | undefined;
}