-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
129 lines (127 loc) · 4.36 KB
/
index.d.ts
File metadata and controls
129 lines (127 loc) · 4.36 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import type { HttpMethods, routeFNOpts, Server } from "@ublitzjs/core";
import type {
ComponentsObject,
InfoObject,
TagObject,
EncodingPropertyObject,
ExternalDocumentationObject,
ISpecificationExtension,
OpenApiBuilder,
ParameterObject,
ReferenceObject,
RequestBodyObject,
ResponseObject,
SecurityRequirementObject,
ServerObject,
} from "openapi3-ts/oas31";
interface CallbacksObject extends ISpecificationExtension {
[name: string]: CallbackObject | ReferenceObject;
}
interface CallbackObject extends ISpecificationExtension {
[name: string]: PathItemObject;
}
interface ResponsesObject {
default?: ResponseObject | ReferenceObject;
[statuscode: string]: ResponseObject | ReferenceObject | undefined;
}
interface OperationObject extends ISpecificationExtension {
tags?: string[];
summary?: string;
description?: string;
externalDocs?: ExternalDocumentationObject;
operationId?: string;
parameters?: (ParameterObject | ReferenceObject)[];
requestBody?: RequestBodyObject | ReferenceObject;
responses?: ResponsesObject;
callbacks?: CallbacksObject;
deprecated?: boolean;
produces?: string[];
security?: SecurityRequirementObject[];
servers?: ServerObject[];
}
interface EncodingObject extends ISpecificationExtension {
[property: string]: EncodingPropertyObject;
}
interface OpenAPIObject extends ISpecificationExtension {
openapi: string;
info: InfoObject;
servers?: ServerObject[];
paths?: PathsObject;
components?: ComponentsObject;
security?: SecurityRequirementObject[];
tags?: TagObject[];
externalDocs?: ExternalDocumentationObject;
webhooks?: PathsObject;
}
interface PathsObject extends ISpecificationExtension {
[path: string]: PathItemObject;
}
interface PathItemObject extends ISpecificationExtension {
$ref?: string;
summary?: string;
description?: string;
get?: OperationObject;
put?: OperationObject;
post?: OperationObject;
delete?: OperationObject;
options?: OperationObject;
head?: OperationObject;
patch?: OperationObject;
trace?: OperationObject;
servers?: ServerObject[];
parameters?: (ParameterObject | ReferenceObject)[];
}
/**
* use it with "extPaths" type from @ublitzjs/router" or with 'server.route' from 'core' package
* @see examples on github
*/
export type routeAddOns = {
openapi?: {
$ref?: string;
summary?: string;
description?: string;
servers?: ServerObject[];
parameters?: (ParameterObject | ReferenceObject)[];
};
};
/**
* use it with "extPaths" type from @ublitzjs/router" or with 'server.route' from 'core' package
* @see examples on github
*/
export type methodAddOns = { openapi?: Partial<OperationObject> };
/**
* function, which should be put into "extendApp"
* @see https://github.com/ublitzjs/openapi/blob/main/examples/index.ts
*/
export function serverExtension(opts: OpenAPIObject): {
openApiBuilder: OpenApiBuilder;
/**
* @param prefix url on which openapi will be served. You should note that an access to html page is kinda tricky: if prefix = "/docs", then you can't access http://localhost:port/docs BUT can access http://localhost:port/docs/ with the last slash. Or, if you want, just use http://localhost:port/docs/index.html - definitely works. Such a peculiarity of uWS wildcards.
* @param opts use if don't need to dynamically take openapi from code. Properties: build (whether to build an openapi and to serve after this), path (to an openapi json file), clearMimes (same as in 'static' package "clearMimesList"), uiPath - path to folder with ui (defaults to node_modules/@ublitzjs/openapi/ui)
*/
serveOpenApi(
prefix: string,
opts?: {
build?: boolean;
path?: string;
clearMimes?: boolean;
uiPath?: string;
}
): Promise<void>;
buildOpenApi(filePath: string, exitFromNodejs: boolean): Promise<number>;
};
/**
* This function goes to ExtendedRouter from @ublitzjs/router. registers all methods to openapi
* @see https://github.com/ublitzjs/openapi/blob/main/examples/router.cjs
*/
export function RouterPlugin(methods: string[]): void;
/**
* this function goes to Server.route function from 'core' package. It lets you register all methods to openapi
* @see https://github.com/ublitzjs/openapi/blob/main/examples/index.ts
*/
export function routePlugin<method extends HttpMethods>(
route: routeFNOpts<method> & methodAddOns,
server: Server & {
openApiBuilder: OpenApiBuilder;
}
): void;